Write a program to check whether a given number is a
palindrome or not?

Answer Posted / upendar

This Script checks the given number as well as string is palindrome or not


<html>
<body>
<script type="text/javascript">
function checkPalindrome() {
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+" -is Palindrome");
} else {
alert(str+" -is not a Palindrome");
}
}
</script>
<form >
Enter a String/Number: <input type="text" id="str" name="string" /><br />
<input type="submit" value="Check" onclick="checkPalindrome();"/>
</form>
</body>
</html>

Is This Answer Correct ?    437 Yes 107 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to define name function in javascript?

709


What is the difference between undefined and object?

719


What value does prompt() return if the user clicked the cancel button?

659


What is the importance of javascript?

689


How do we add javascript onto a web page?

712


Is javascript free to use?

661


What is the use of blur function in JavaScript?

732


What is an empty html tag?

654


How do I turn on javascript in google chrome?

731


How to handle exceptions in JavaScript?

687


What does parse Query String return in javascript?

697


How are DOM utilized in JavaScript?

852


What are two-way data binding and one-way data flow, and how are they different?

774


What is a javascript code?

690


List different ways of empty an array in javascript?

620