Skip to content

Instantly share code, notes, and snippets.

@adambom
Created June 29, 2012 21:03
Show Gist options
  • Save adambom/3020629 to your computer and use it in GitHub Desktop.
Save adambom/3020629 to your computer and use it in GitHub Desktop.
Is Palindrome??
function isPalindrome(n) {
var str, firstDigit, lastDigit;
str = String(n).replace(".", "").split("");
if (str.length < 2) {
return false;
}
firstDigit = str.shift();
lastDigit = str.pop();
if (firstDigit !== lastDigit) {
return false;
}
if (str.length < 2) {
return true;
} else {
return isPalindrome(Number(str.join("")));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment