Palindrome Checker problem with stingify

HI! I need your help. I’m wondering why I can’t pass two tests:

  • palindrome("_eye") should return true.
  • palindrome(“0_0 (: /- :slight_smile: 0-0”) should return true.
    Here is my code :
function palindrome(str) {
  
  var reversed = str.toLowerCase().replace(/\W/g, '').split("").reverse();
  var orgStr = str.toLowerCase().replace(/\W/g, '').split("");

    if(JSON.stringify(orgStr)==JSON.stringify(reversed)) 
    {
      return true;
    }
    else return false;

}
palindrome("eye");
`var reversed = str.toLowerCase().replace(/\W/g, '').split("").reverse();` Thats because in this line you didn't join the string up after you split it. You'll just need to add in a `.join("")` function at the end of the reverse to rectify your problem.

Edit:
It was just your regex that was wrong, my bad about that!
Underscore is not included inside the “not word” rule.
So you’ll need to write .replace(/\W|_/g, '') or .replace(/[\W_]/g, '').

Thank you ery much for your help :slight_smile: