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
What is the microsoft version of javascript?
What does the isNaN() function?
Are there any iphone Institutes which also train iphone automation testing in Hyderabad?
How long does it take to learn javascript?
Difference between the substr() and substring() in JavaScript?
TypeError: document.getelementbyid(...) is null?
How do you implement Ajax using hide() function in JQuery?
How do I enable cookies safari?
Which built-in method removes the last element from an array and returns that element?
How to show progress bar while loading using ajax call?
Name some of the JavaScript features?
What is js full form?
What is NaN?
What are exports & imports?
Is function a data type in javascript?