Check for Palindromes Challenge Problem

function palindrome(yourInput) {
var pattern = /[\s\d-!$%^&*()_+|~=`{}[]:";’<>?,./]/g;
yourInput = yourInput.toLowerCase();
yourInput = yourInput.replace(pattern,"");
var array = yourInput.split("");
var arrayReversed = array.reverse();
var strTwo = arrayReversed.join("");
if(yourInput == strTwo){

return true;

}else{
return false;
}

}

palindrome(“1 eye for of 1 eye.”);

Hello. I have been trying to solve this challenge but the only mistake the code says I have made is the one above: the sentence “1 eye for of 1 eye.” should return false. Instead it returns true, but I think the sentece is actually a palindrome if we consider the parameters of the challenge. So what am I doing wrong here? Thank you in advance for your reply.

You shouldn’t be removing numbers from the string, "You’ll need to remove all non-alphanumeric characters ". Numbers are alphanumeric.

1 Like

Thank you very much. It was really helpful.Have a nice day.

1 Like