Tell us what’s happening:
I have all the conditions met except checking for “1 eye for of 1 eye.”. My code checks if it’s the same reversed with the non-alphanumeric characters removed and lower cased. Am I missing something?
Your code so far
function palindrome(str) {
// Good luck!
var basicStr = "";
str = str.toLowerCase();
basicStr = str.replace(/[^A-Za-z]/gi, '');
//reversed str
var arr;
var newStr;
arr = basicStr.split("");
arr = arr.reverse();
newStr = arr.join("");
//return newStr;
if(newStr == basicStr)
{
return true;
}
else
{
return false;
}
}
palindrome("1 eye for of 1 eye.");
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Safari/604.1.38
.
Link to the challenge: