Friday, October 23, 2015

Number Palindrome in JavaScript

This program that I wrote in JavaScript will ask the user to enter a number and then our program will check and determine if the given number by the user is a palindrome or not a palindrome.

If you  have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing


<html>
<head>
  <title>Number Palindrome </title>
</head>
<style>
h3 {
   font-family:arial;
   };
 </style>
<body>
  <script>
    
var num_value = (prompt("Enter number: "));
var rev_number = "";
var b = num_value.length;
document.write("<br>");
document.write("<h3> Number Palindrome</h3>");
     
 for(var a=b; a>=0; a--)
    {
    rev_number = rev_number+num_value.charAt(a);
    }
 
   if ( num_value==rev_number){
      document.write("<font face='arial' size='3'>");
      document.write(num_value + " is a Palindrome Number. </font> <br>");
 }
   else 
     {
 document.write("<font face='arial' size='3'>");
      document.write(num_value + " is a not Palindrome Number. </font> <br>");
     }  
document.write("<h3> End of Program </h3>");
</script>
</body>
</html>



No comments:

Post a Comment