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

discuss scoping in javascript?

529


Does javascript support automatic type conversion?

665


What is callback in javascript?

493


What are the features of javascript?

482


How do I view javascript in chrome?

506






What is an immediately-invoked function expression?

497


What is encodeuri() function?

545


What can I build with javascript?

498


What is the difference between ‘let’ and ‘const’?

556


How to get the last index of a string in javascript?

497


How do I open javascript in chrome?

461


What javascript method would convert the string “20” to an integer (on the fly) so “20” + 20 = 40?

523


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

460


How do I use javascript to password-protect my web site?

486


How to define name function in javascript?

531