Skip to content

Instantly share code, notes, and snippets.

@Wolfy64
Last active May 15, 2018 23:24
Show Gist options
  • Save Wolfy64/4d6b1294a901d8df627b81a9f5a4eb8b to your computer and use it in GitHub Desktop.
Save Wolfy64/4d6b1294a901d8df627b81a9f5a4eb8b to your computer and use it in GitHub Desktop.
palindrome JS
function palindrome(str) {
regExp = /[^a-z\d]/gi; // Keep every letters and digits
word = str.toLowerCase().replace(regExp, '');
palindrome = word.split('').reverse().join('');
return palindrome === word;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment