Sunday, December 11, 2016

Palindrome Checker in JavaScript

In this article I wrote in JavaScript that will ask the user to give a string or a word and then the program will check and determine if the given word or string is a palindrome or not a palindrome.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

<html>
<body bgcolor="yellow">

<script type="text/javascript">
  function Palindrome() {
   var revStr = "";
   var str = document.getElementById("str").value;
   var i = str.length;
   for(var j=i; j>=0; j--) {
      revStr = revStr+str.charAt(j);
   }
   if(str == revStr) {
      alert(str.toUpperCase() + " is Palindrome");
   } else {
      alert(str.toUpperCase() + " is not a Palindrome");
   }
}
</script>
<font color="blue" size="6">
 <center>
Palindrome Checker 1.0 <br>
<font size="3">
Created By <br>
Mr. Jake R. Pomperada, MAED-IT
</center>
 <br>
</font>

<form >
<font color="blue" size="4">
  Enter a Word or a Number: <input type="text" id="str" name="string" /><br />
  <br>
  <input type="submit" value="Check For Palindrome" onclick="Palindrome();"/>
</font>
</form>

</body>
</html>





No comments:

Post a Comment