Created
October 12, 2020 03:07
-
-
Save TechWithTy/7346edf8b39009d025aacd3f14545ed0 to your computer and use it in GitHub Desktop.
Find out if value is a palindrome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {number} x | |
* @return {boolean} | |
*/ | |
var isPalindrome = function(x) { | |
let reversedNum = 0 | |
//Passes | |
if(x < 0){ | |
return false; | |
}else{ | |
reversedNum = x.toString().split('').reverse().join(''); | |
return (x == reversedNum ? true: false); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment