In javascript, checking if a number/string is a palindrome is easy, however... Follow up: Could you solve it without converting the integer to a string?
/**
* @param {number} x
* @return {boolean}
*/
var isPalindrome = function(x) {
if(x < 0) return false;
let num = x;
let res = 0;
while(num) {
let last = num % 10;
// take res as of type "string", but it's still a type of number
res = res * 10 + last;
num = Math.floor(num / 10);
}
return x === res
};