How to check if a number is palindrome in Node.js

1 Answer

0 votes
function isPalindrome(num) {
    let strnum = num.toString();
     
    return strnum === [...strnum].reverse().join('');
}
         
const num = 12321; 
 
console.log(isPalindrome(num) ? "yes" : "no");

 
 
     
/*
run:
     
yes

*/

 



answered Jan 8, 2024 by avibootz
...