The prompt:

Given a number, write a function that can determine if the specified number is a palindrome. For example 134 is not a palindrome because reversing it results in 431. A palindrome would return the same value, for example 313 is a palindrome because reversing it results in the same number, 313 again.

Solution

/** * @param {number} x * @return {boolean} */ var isPalindrome = function(x) { if(x<0) { return false } let str = "" + x let rs = str.split("").reverse().join("") if(rs !== str) { return false } return true }; // Some test cases ` False Expected: ${isPalindrome(123)} True Expected: ${isPalindrome(3443)} False Expected: ${isPalindrome(6215)} True Expected: ${isPalindrome(18781)} False Expected: ${isPalindrome(-51)} `;