Regarding the Palindrome Checker

Tell us what’s happening:
In the test case, one of the condition is " palindrome("1 eye for of 1 eye.") should return false ."

here if I remove all the symbols and numbers I get - eyeforofeye which in reverse is eyeforofey so it should give true. But it’s expecting false. Why?

  **Your code so far**

function palindrome(str) {

  const arr = str.match(/[a-z]/gi)

  if (arr === null) {
    return true;
  } 

  str = arr.join("").toLowerCase()
  const rev_str = arr.reverse().join("").toLowerCase()
  
  if(str === rev_str) {
    return true;
  }

  return false;
}

palindrome("eye");

  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36

Challenge: Palindrome Checker

Link to the challenge:

The requirement is to ignore all non-alphanumeric characters. So the numerals 0-9 should be counted.

I see. Got it. Thanks.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.