Write a program to check whether a given number is a
palindrome or not?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / riddhi
<html>
<head>
<script language="Javascript">
var a;
</script>
<title> Number Palindrom </title>
</head>
<body>
<script Language="Javascript">
var rno=0;
var r=0;
var no = prompt("Enter First no: ","10");
var ono = parseInt(no);
while (no>0)
{
r = parseInt(no%10);
rno = parseInt((rno*10)+r);
no = parseInt(no/10);
}
document.write(rno);
if(rno == ono)
{
document.write(ono+" is palindrom number..");
}
else
{
document.write(ono +" is not palindrom number..");
}
</script>
</body>
</html>
Is This Answer Correct ? | 72 Yes | 39 No |
Answer / dk
<html>
<body>
<script type="text/javascript">
var n,n1,s,d;
n=prompt('Enter a Number.');
n1=n;
s=0;
while(n!=0)
{
d=n%10;
n=(n-d)/10;
s=(10*s)+d;
}
if(s==n1)
document.write(n1+" is a palindrome");
else
document.write(n1+" is not a palindrome");
</script
</body>
</html>
Is This Answer Correct ? | 36 Yes | 8 No |
Answer / sharma v
num=InputBox ("Enter a number")
z=num
r=0
While(num>0)
rem1=num mod 10
num=num\10
r=(r*10) + rem1
Wend
If (r=z)Then
Msgbox "Given no is palindrome"
else
Msgbox "Given no. is not palindrome"
End If
Is This Answer Correct ? | 23 Yes | 17 No |
Answer / ankita
//Program to check the given number is palindrome or not//
<html>
<head>
<script language="javascript">
var num,n,rev=0,r;
num=prompt("Enter the number");
n=num;
while(parseInt(num)>0)
{
r=parseInt(num)%10;
rev=parseInt(rev)*10+parseInt(r);
num=parseInt(num)/10;
}
if(rev==parseInt(n))
document.write(n+ " is a palindrome number");
else
document.write(n+ " is not a palindrome number");
</script>
</head>
<body>
</body>
</html>
Is This Answer Correct ? | 8 Yes | 2 No |
Answer / kamal kumar
<script>
function bon()
{
var y="";
var j= document.getElementById("ty").value;
var k = j.split('');
for(var l= k.length; l>0; l--)
{
y+=k[l-1];
}
if(j==y)
{
alert("This is Palidrome");
}
else
{
alert("This not Palidromn");
}
}
</script>
<body>
<input type="number" id="ty">
<button onclick=" bon()"> Come On!</button>
</body>
Is This Answer Correct ? | 1 Yes | 0 No |
How can I prevent others from reading/stealing my scripts or images?
why is java platform indipedence
How to make a array as a stack using javascript?
What would you use javascript for?
Which built-in method calls a function for each element in the array?
How to force a page to go to another page using javascript ?
What is let keyword in typescript?
How to use one javascript function for multiple input fields?
Is array a data type in javascript?
What will be the output of the following code? //nfe (named function expression) var Foo = Function Bar() { return 7; }; typeof Bar();
Explain the difference between call() and apply()?
Can I write javascript in notepad?