// running tests
palindrome(“1 eye for of 1 eye.”)
should return
false
I keep getting this message and the test fails, but according to the requirements of the quiz, and the definition of a palindrome, the string “1 eye for of 1 eye” is a palindrome (once all non-alpha characters are stripped away).
**Your code so far**
function palindrome(str) {
//remove spaces
var stripped = str.replace(/[\d\W_]/g, '');
var str1 = stripped.toLowerCase().split(" ");
var str_concat = "";
for(let i = 0; i < str1.length; i++){
str_concat+= str1[i];
}
var arr = str_concat.split("");
var revArr = str_concat.split("");
revArr.reverse();
var f = 0;
if (arr.length == revArr.length)
{
for(let i = 0; i < arr.length; i++){
if( arr[i] != revArr[i]){
f +=1;
}
}
}
if(f > 0){
return false;
}
else{
return true;
}
}
palindrome("eye");
**Your browser information:**
User Agent is: Mozilla/5.0 (X11; CrOS aarch64 14324.62.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.77 Safari/537.36
Challenge: Palindrome Checker
Link to the challenge: