Last active
May 15, 2018 23:24
-
-
Save Wolfy64/4d6b1294a901d8df627b81a9f5a4eb8b to your computer and use it in GitHub Desktop.
palindrome JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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