Why does this work in Java but not in JavaScript? I tried using this in Java and its working perfectly fine but I can't figure out why it's only printing "Not a palindrome" in JavaScript? thank you
var n = 121;
var sum = 0, r;
var temp = n;
while(n>0)
{
r = n % 10;
sum = (sum*10)+r;
n = n/10;
}
if(temp==sum)
console.log("It is a Palindrome number.");
else
console.log("Not a palindrome");