function palindrome(str) {
var s=str.replace(/[\W_]/g ,"").toLowerCase();
var b=str.split("").reverse().join("");
return s===b;
}
palindrome("race car");
you have return s === b which is asking your code to tell you if s is equal to b, and its not, so your code will return false.
other than that, you’ve manipulated str with var s, then did a completely separate manipulation on the same str with var b.
I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.