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 / abhijeet gupta

var num=123211;
var str=""+num;
for(var i=0;i<str.length/2;i++){
if(str.charAt(i)!==str.charAt(str.length-1-i)) {
console.log("Not Palindrome");
return;
}
}
console.log("palindrome")

Is This Answer Correct ?    3 Yes 3 No

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

Answer / annshuk

function isPalidrome(str){
if(str== str.split('').reverse().join())
return str +"is palidrome";
else return str +"try another string";
}

Is This Answer Correct ?    0 Yes 4 No

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

Answer / james

102101

Is This Answer Correct ?    3 Yes 9 No

Post New Answer

More JavaScript Interview Questions

You have an asp. Net web application running on a web-farm that does not use sticky sessions - so the requests for a session are not guaranteed to be served the same machine. Occasionally, the users get error message validation of view state mac failed. What could be one reason that is causing this error?

0 Answers  


how to use java script

1 Answers   Infosys,


What is javascript hoisting?

0 Answers  


How can you get the reference of a caller function inside a function?

0 Answers  


What is push() method in javascript?

0 Answers  


Describe the properties of an anonymous function in JavaScript?

0 Answers  


What are the methods of validating whether the form is secure?

1 Answers  


What is null in javascript?

0 Answers  


you will be creating 2 files, a .html page and a separate JavaScript function file with the .js extension. For submission, you must zip the 2 files into 1 file and upload the zipped file to my website. This assignmen t is meant to get you comfortable with utilizing functions located in a separate function file (as demonstrated in class on Tuesday May 7 th ) Javascript Function file This file will simply contain 2 functions. One called findAvg() which takes in 2 values and returns the average. Another called findMax() which takes in 2 values and returns the maximum. HTML page Create a form for the user to enter 2 integers and a pull down menu wit h the following options listed ... Find Averag e Find Maximum And a button. See my sample output for ass istance on the layout. Once the button is clicked, have your ‘ main ’ javas cript function obtain the i nput including the option chosen in the pull down menu (remember, you mjust set a value for each me nu option so JavaScript can determine which function to use) . If the user selects ‘ Find Averag e ’ , call the findAvg() function from the external file. And so on for the other menu options. Output the result to a <DIV> tag on the webpage. Please note that you must use an external file to hold your functions

0 Answers  


What is array in javascript?

0 Answers  


What is object in javascript?

0 Answers  


How do I enable cookies and javascript?

0 Answers  


Categories