Tell us what’s happening:
Hello, it seems like the code is fine(?), but no matter what string I call (e.g. ‘Panama’) it gives ‘true’. Is there anything wrong with the if else statement?
Can anyone take a look, please?
Your code so far
function palindrome(str) {
var a = /\W/gi;
var myString = str.toLowerCase().replace(a, '').reverse;
if (str === myString); {
return true;
}else {
return false;
}
}
palindrome("A man, a plan, a canal. Panama");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36
.
Link to the challenge: