Skip to content

Instantly share code, notes, and snippets.

@bignimbus
Last active August 29, 2015 14:10
Show Gist options
  • Save bignimbus/15d62987b65764dff044 to your computer and use it in GitHub Desktop.
Save bignimbus/15d62987b65764dff044 to your computer and use it in GitHub Desktop.
detects whether a string is a palindrome
function isPalindrome (str) {
if (typeof str !== 'string') {
return false;
}
var n,
letters = str.split(''),
len = letters.length - 1;
for (n = 0; n <= len; n++) {
if (n !== len - n && letters[n] !== letters[len - n]) {
return false;
}
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment