Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.37 KB | None | 0 0
  1. const isPalindrome = num => parseInt(num.toString().split('').reverse().join(''), 10) === num;
  2.  
  3. // The problem is that I wasn't returning the result of the nextPalindrome recursive call
  4. // I think this works now
  5. const nextPalindrome = (num) => {
  6. if(isPalindrome(num)) {
  7. return num;
  8. } else {
  9. return nextPalindrome(num + 1);
  10. }
  11. };
  12.  
  13. console.log(nextPalindrome(91));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement