Write a program to check whether a given number is a
palindrome or not?
Answer Posted / 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 |
Post New Answer View All Answers
List different ways of empty an array in javascript?
just for testing
Is python better than javascript?
What is arguments object in JavaScript?
What is the difference between push() and concat() in javascript?
What do ellipses mean in javascript?
How do I open javascript console?
What are two-way data binding and one-way data flow, and how are they different?
How to open url in a new tab in javascript?
What web sites do you feel use javascript most effectively (i.e., Best-in-class examples)? The worst?
Can you explain how inheritance works in javascript?
How do you clear an array in javascript?
What is the difference between ‘let’ and ‘const’?
What’s relationship between javascript and ecmascript?
Write a main method that prompts the user to enter the starting population, birth and death rates, and the number of years. The input birth and death rates cannot be negative, the starting population cannot be less than 2, and the number of years greater than 0. If the user enters an invalid value, this program will prompt user to re-enter the value until a valid value has been read. When all input values are valid, call on the methods above to compute estimated population and print result.