A palindrome is a number or a text phrase that reads the same backward and forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write a script that reads in a five-digit integer and determines whether it is a palindrome. If the number is not five digits long, display an alert dialog indicating the problem to the user. Allow the user to enter a new value after dismissing the alert dialog. [Hint: It is possible to do this exercise with the techniques learned in this chapter. You will need to use both division and remainder operations to "pick off" each digit.]

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title> Palindrome </title>
<script type="text/javascript">
<!--
var number;
number = window.prompt("Enter any 5 Digit number:");
var n = parseInt(number);
while(n<10000 n > 99999 )
{
window.alert("The Number is not a five digit number");
number = window.prompt("Enter any 5 Digit number:");
n = parseInt(number);
}
var digit1 = n%10;
n = n/10;
var digit2 = n%10;
n = n/10;
var digit3 = n%10;
n = n/10;
var digit4 = n%10;
var digit5 = n/10;
if(parseInt(digit1)==parseInt(digit5))
{
if(parseInt(digit2)==parseInt(digit4))
{
document.writeln( "<h1>" + number + " is a Palindrome </h1>" );
}
}
else
{
document.writeln( "<h1>" + number + " is not a Palindrome </h1>" );
}
// -->
</script>
</head>
<body>
<h1> Palindrome </h1>
<hr />
<p> Click Refresh(F5) or reload to run this script again</p>


</body>
</html>