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
How to write comment in JavaScript?
What is webassembly good for?
What is event bubbling and capturing in javascript?
What is postback in javascript?
How to port a GUI application onto Web
What is the use of isNaN function?
What and where are the best javascript resources on the web?
What percentage of websites use javascript?
Why is javascript so hard?
What is npm javascript?
What does js stand for?
How to remove the event listener?
How to shift and unshift using javascript?
What is difference between deep and shallow object coping in javascript?
What is output of undefined * 2 in javascript?