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
Does javascript care about whitespace?
What are the pop-up boxes available in javascript?
Can javascript code be broken in different lines?
What can be the challenges during testing a program or a system?
Why extending array is bad idea?
Have you used any browser for debugging? If yes, how is it done?
How to create an object in javascript?
What are nodes in javascript?
What is output of “20” + 20 + 20 and “20” + ( 20 + 20)? In javascript?
what is the difference between wrappers and primitives es: diff between int i=200 in primitives and integeri = new integer(54)
What are the data types available in javascript? Explain
What do you mean by script?
What is a javascript symbol?
What is unobtrusive javascript? How to add behavior to an element using javascript?
How do I turn on javascript on my phone?