Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const isPalindrome = num => parseInt(num.toString().split('').reverse().join(''), 10) === num;
- // The problem is that I wasn't returning the result of the nextPalindrome recursive call
- // I think this works now
- const nextPalindrome = (num) => {
- if(isPalindrome(num)) {
- return num;
- } else {
- return nextPalindrome(num + 1);
- }
- };
- console.log(nextPalindrome(91));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement