Skip to content

Instantly share code, notes, and snippets.

@tiberiur
Created February 2, 2017 16:44
Show Gist options
  • Save tiberiur/64fe7c464fb31650441d93ca700a0e57 to your computer and use it in GitHub Desktop.
Save tiberiur/64fe7c464fb31650441d93ca700a0e57 to your computer and use it in GitHub Desktop.
[JS] Check for Palindromes
function palindrome(str) {
var text = str.replace(/[^0-9a-z]/gi, '').toLowerCase(),
reverseText = text.split("").reverse().join("");
return text == reverseText;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment