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 define name function in javascript?
What is the difference between undefined and object?
What value does prompt() return if the user clicked the cancel button?
What is the importance of javascript?
How do we add javascript onto a web page?
Is javascript free to use?
What is the use of blur function in JavaScript?
What is an empty html tag?
How do I turn on javascript in google chrome?
How to handle exceptions in JavaScript?
What does parse Query String return in javascript?
How are DOM utilized in JavaScript?
What are two-way data binding and one-way data flow, and how are they different?
What is a javascript code?
List different ways of empty an array in javascript?