Why is my test case failing?

Tell us what’s happening:
Every test case is passing except “1 eye for of 1 eye.”…I logged the array I created in console and the output was a palindrome yet the case keeps failing.

Your code so far

function palindrome(str) {
let newArr = str.replace(/[^a-zA-Z]+/g, "").toLowerCase().split('');
for(let i = 0; i < newArr.length; i++){
  if(newArr[i] !== newArr[newArr.length-i-1]) return false
return true;

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

Your browser information:

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

Challenge: Palindrome Checker

Link to the challenge:

because you need to consider alphanumerical characters
you are just checking letters. If you consider also the 1s then you will see that that string is not a palindrome, if you consider only letters it will result as so

your function needs to say that that string is not a palindrome

1 Like