Created
November 18, 2019 08:47
-
-
Save imkrish/cc377c05332e26fec051e08bff99ce30 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
//Make the following test cases pass | |
function isPalindrome(phrase) { | |
const SPACE = " "; | |
const lowerCharsInPhrase = phrase | |
.toLowerCase() | |
.split("") | |
.filter(char => char !== SPACE); | |
return lowerCharsInPhrase.join() === lowerCharsInPhrase.reverse().join(); | |
} | |
function check(phrase, shouldBePalindrome) { | |
console.log(isPalindrome(phrase) === shouldBePalindrome ? "PASS" : "FAIL"); | |
} | |
check("abcba", true); | |
check("abcde", false); | |
check("Mr owl ate my metal worm", true); | |
check("Never Odd Or Even", true); | |
check("Never Even Or Odd", false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment