Last active
August 22, 2020 14:26
-
-
Save vldvel/711baf4f7f9175550ce21eddbded9cae to your computer and use it in GitHub Desktop.
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
const string1 = 'level'; | |
const string2 = 'Le, vel.'; | |
const isPalindrome = stringToTest => { | |
const stringTransformed = stringToTest | |
.replace(/[^\w]/gi, '') // replace all non-letter characters | |
.toLowerCase(); // make all characters lower cased | |
return stringTransformed === stringTransformed.split('').reverse().join(''); | |
} | |
isPalindrome(string1); // true | |
isPalindrome(string2); // true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment