Tell us what’s happening:
I have solved the problem but I am not sure if this is the right way or could be a better or right way to do it.
I searched for all non-alphanumeric char and some said /\W/g would do it. but this underscore _ still would not replaced. the Rest as you can see.
Please review and would love to hear your input.
Your code so far
function palindrome(str) {
var str0 = str.replace(/\W/g, '').replace(/_/g, '').replace(' ', '').toLowerCase();
var str1 = str0.split('').reverse().join('');
return str0 === str1;
}
palindrome("eye");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36
.
Link to the challenge: