Tell us what’s happening:
My function takes a string in as a parameter and returns true if it is a palindrome (a word which is read the same forward as backward). So far it returns true even if the parameter is not a palindrome. What have I done wrong?
Your code so far
function palindrome(str)
{
// Good luck!
str.toLowerCase();
str.replace(/ /, "");
str.replace(/_/, "");
var backStr = str.split();
backStr.reverse();
if(backStr.join("") === str)
{
return true;
}
else
{
return false;
}
}
palindrome("nope");
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: