Created
April 19, 2019 17:25
-
-
Save leolanese/06acd13f5ac1d78615065044c71a2a7e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 isPalindrome(str) { | |
str = str.replace(/\W/g, '').toLowerCase(); | |
return (str == str.split('').reverse().join('')); | |
} | |
console.log(isPalindrome("level")); // logs 'true' | |
console.log(isPalindrome("levels")); // logs 'false' | |
console.log(isPalindrome("A car, a man, a maraca")); // logs 'true' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment