Check for Palindromes Challenge Problem

Check for Palindromes Challenge Problem
0.0 0

#1

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.


#2

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


#3

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