Can't find my error on Palindrome Checker

Tell us what’s happening:

“1 eye for of 1 eye.” == to alphabets only ==> ‘eyeforofeye’
the system says it should return false
but my code return true.
so i fail the check.
But I can’t find out whats wrong with my implementation.
as far as my knowledge, its a palindrome.
Please spot me what i missed.

Your code so far


function palindrome(str) {
str=str.split(/\W*\d*[_]*/).join('').toLowerCase()
console.log(str)
console.log(str.length,str.length/2 >>0)
for(var i=0;i<str.length/2 >>0;i++){
        console.log(str[i], '== ',str[str.length-i-1])

  if(str[i]!=str[str.length-i-1]){
    return false
  }
}

return true;
}
palindrome("1 eye for of 1 eye.")

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36.

Challenge: Palindrome Checker

Link to the challenge:

I think the problem is your regex is flagging numbers (\d), but you’re supposed to keep all alpha-numeric characters. That’s why your implementation is returning true: you’re not taking into account the numbers.

1 Like

Thank you for your help.
My problem is I didn’t notice the term alpha-numeric and I thought I’ve to check only the alphabets.