Why my code doesn't work in palindrome checker?

Hello!
I’m trying to do the code for detecting palindromes, in this challenge
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/palindrome-checker

and my code is too similar of the solution 1, but doesn’t work in palindrome("five|_/|four");

function palindrome(str) {
  let str1= str.replace(/[\W_]/g, "").toLowerCase();
  if (str1 === str1.split("").reverse().join(""));
  return true;
}
palindrome("five|_/|four");

Thanks!

Your function always returns true, because you do nothing with that if statement, you just terminate it with a semicolon.

Maybe check again how if statements are written:

if (condition to check) {
    // do stuff
} else {
    // do other stuff
}

your lfunction always returns true or undefined

maybe, instead of being the condition, you could use yourcomparison in a different way

what a silly thing I have left! thanks a lot!

I mean, return str1 === str1... is also a good way, it’s also more compact

i think so, when it work! Thanks!