JavaScript Algorithms and Data Structures Projects: Palindrome Checker/Regex problem?

Tell us what’s happening:
Hi, i managed to pass all the tests except for this one: palindrome("1 eye for of 1 eye.") should return false.
i don’t know what is wrong, any help would be appreciated.

Your code so far

function palindrome(str) {
let revStr = str.split("").reverse().join("");
let reverseStr = revStr.replace(/[\W\d_\s]/g, '').toLowerCase();
let originalStr = str.replace(/[\W\d_\s]/g, '').toLowerCase();
if (originalStr === reverseStr) {
  return true;
}else {
  return false;

let result = palindrome("1 eye for of 1 eye.");

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0.

Challenge: Palindrome Checker

Link to the challenge:

you need to check alphanumerical characters, it is you are only checking letters

but the non-alphanumeric characters aren’t covered with [\W]?

\W equals to [^a-zA-Z0-9_] (so everythint but letters numbers and underscore)

you need to look at the whole pattern, you are also removing numbers with \d

1 Like

thank you so much, i forgot why i put that there.