Javascript examples for Number Operation:Number Algorithm
Determine whether an integer is a palindrome. Do this without extra space.
/*// w w w .j a v a 2 s . co m Determine whether an integer is a palindrome. Do this without extra space. */ function isPalindrome(x) { let reversed, original let arr = x.toString().split('').map(function(y){ return parseInt(y) }) original = parseInt(arr.join('')) reversed = parseInt(arr.reverse().join('')); if (reversed === original) { return true } else { return false }; }