Please help understand Why the test palindrome("1 eye for of 1 eye.") is failing

Tell us what’s happening:
The test palindrome(“1 eye for of 1 eye.”) is failing as its returning true while its expected to be false. Although it seems that ‘eyeforofeye’ is palindrome and my code is returning the both str and reversed as same .

Your code so far

function palindrome(str) {
let alphaStr = str.replace(/[^a-z]/ig,"").toLowerCase();
let rvrsdalphaStr = ""
let lenofstr = alphaStr.length - 1
for (let i = lenofstr ; i >= 0 ; i--) {
  rvrsdalphaStr +=  alphaStr[i] ;

return alphaStr === rvrsdalphaStr

console.log(palindrome("1 eye for of 1 eye."));

palindrome("1 eye for of 1 eye.") should return false

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0.

Challenge: Palindrome Checker

Link to the challenge:

You are removing the numbers from the string.


I was pondering long and hard about the solution but missed the requirement that it has to be alphanumeric.
Thanks a lot

The devil likes to hide in those details. :slight_smile: Happy coding!