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
Name some of the JavaScript features?
How to write html code dynamically using JavaScript?
What are the problems associated with using javascript, and are there javascript techniques that you discourage?
How do you check if a variable is an object
What are the different types of errors supported by javascript?
How do you write an event emitter base class that allows you to add event listeners?
Explain higher-order functions in javascript?
why we calld java object orinted programming language??
How to write a comment in javascript?
What is the function of delete operator?
What is javascript used for on iphone?
What is the importance of javascript? Expalin
How will you create new object in javascript?
What is the use of javascript?
Explain what is javascript? List some data types supported by javascript?