Skip to content

Instantly share code, notes, and snippets.

@bflannery
Created December 20, 2016 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bflannery/a060975a51225fd385932e5dade77849 to your computer and use it in GitHub Desktop.
Save bflannery/a060975a51225fd385932e5dade77849 to your computer and use it in GitHub Desktop.
Palindrome Checker
// Return true if the given string is a palindrome. Otherwise, return false.
function palindrome(str) {
var x = str.replace(/[^a-z0-9+]+/gi, '').toLowerCase();
if(x.split('').reverse().join('') === x) {
return true;
} else {
return false;
}
}
console.log(palindrome("eye"));
console.log(palindrome("2A3*3a2"));
console.log(palindrome("1 eye for of 1 eye."));
console.log(palindrome("My age is 0, 0 si ega ym."));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment