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
Are there any training Institutions on iphone Automation testing?
Is it possible to break javascript code into several lines?
What is the best free ide?
What is difference between undefined variable and undeclared variable?
How to calculate fibonacci numbers in javascript?
Define unescape() and escape() functions?
What does the term sticky session mean in a web-farm scenario?
What is the difference between arrow function and normal function?
How do you change the style/class on any element using javascript?
Is javascript event driven?
How to add buttons in javascript?
Is a hash table an array?
Explain function hoisting in javascript?
Is javascript client side or server side?
How dhtml is used in javascript?