Palindromes code review

“check in palindrome”

Can someone help review my code? All tests pass except for

  1. palindrome(“A man, a plan, a canal. Panama”) should return true.
  2. palindrome(“My age is 0, 0 si ega ym.”) should return true.

This is my code:

function palindrome(str) {

str = str.replace(/[^a-z0-9+]+/gi, ‘’);
var newString = str.split("").reverse().join("").toLowerCase();

if(newString === str){

return true;

}
else{
return false;
}
}

Wow. Thanks a lot for your response. That actually helps a lot. It worked for me, and I learned something new today which is always a great thing. You are my hero!