I don't understand why dosen't work good. So, in Visual Studio Code running, but in LeetCode after i press the button to Run code it will give me one error
const isPalindrome = number => {
const palindrom = number.split('').reverse().join('');
return (palindrom === number) ? palindrom : false;}
Visual Studio Code running :
The problem occurs when you will pass an integer. cast or convert the passed parameter to string then would work.
const isPalindrome = number => {
const palindrom = number.toString().split('').reverse().join('');
return (palindrom == number) ? palindrom : false;}
const res = [];
res.push(isPalindrome(1221));
res.push(isPalindrome("1221"));
res.push(isPalindrome("av"));
console.log(res);