Write a program to check whether a given number is a
palindrome or not?

Answers were Sorted based on User's Feedback



Write a program to check whether a given number is a palindrome or not?..

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

Write a program to check whether a given number is a palindrome or not?..

Answer / srikanth

malayalam

Is This Answer Correct ?    119 Yes 45 No

Write a program to check whether a given number is a palindrome or not?..

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

Write a program to check whether a given number is a palindrome or not?..

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

Write a program to check whether a given number is a palindrome or not?..

Answer / praveen

12121

Is This Answer Correct ?    21 Yes 4 No

Write a program to check whether a given number is a palindrome or not?..

Answer / ss

1221

Is This Answer Correct ?    28 Yes 13 No

Write a program to check whether a given number is a palindrome or not?..

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

Write a program to check whether a given number is a palindrome or not?..

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

Write a program to check whether a given number is a palindrome or not?..

Answer / renuga devi

mam,16061

Is This Answer Correct ?    6 Yes 3 No

Write a program to check whether a given number is a palindrome or not?..

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

Post New Answer

More JavaScript Interview Questions

How can I prevent others from reading/stealing my scripts or images?

0 Answers  


why is java platform indipedence

2 Answers   HCL,


How to make a array as a stack using javascript?

0 Answers  


What would you use javascript for?

0 Answers  


Which built-in method calls a function for each element in the array?

0 Answers  






How to force a page to go to another page using javascript ?

0 Answers  


What is let keyword in typescript?

0 Answers  


How to use one javascript function for multiple input fields?

0 Answers  


Is array a data type in javascript?

0 Answers  


What will be the output of the following code? //nfe (named function expression) var Foo = Function Bar() { return 7; }; typeof Bar();

1 Answers  


Explain the difference between call() and apply()?

0 Answers  


Can I write javascript in notepad?

0 Answers  


Categories