Tell us what’s happening:
only this test fails and for what I see this string should be a palindrome but the challenge say it should not,… any insight about this?
JIC: “eyeforofeye” that’s the word after implement the regex.
Your code so far
function palindrome(str) {
// Good luck!
return str.toLowerCase().replace(/[^a-z]/g, "").split("").reverse().join("") == str.toLowerCase().replace(/[^a-z]/g, "");
}
palindrome("1 eye for of 1 eye.");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Safari/537.36.
Your regex remove everything is not a letter ( a lowercase one).
It means you can’t check correctly any statement with any character that is not a lowercase letter ( there are two digits in your example) ^^
My apologies for resurrecting an older thread but I just wanted to point out that I was struggling to understand why my code wasn’t working until I found this post with a link to the regex article in it.
Thank you very much for that - it quite literally saved me hours of searching and pulling out my hair (which is already gone )
I was able to complete the Palindrome project successfully after finding this post!