Palindrome Checker broken?

Tell us what’s happening:

Sooo I have tested my code on freecodecamps challenge and it passed all test cases except:

palindrome(“1 eye for of 1 eye.”) should return false.
// tests completed

This system is saying it should be false?

my function returns true because Im pretty sure it is true ? or am I tripping?

this is was the results of my personal test:
forward = eyeforofeye
backward = eyeforofeye

forward === backward —TRUE

Your code so far


function palindrome(str) {
  
let forward = "";
let backward = "";

for(let i =0; i< str.length;i++){
    
    if(/^[a-zA-Z]/.test(str[i]))
    {
        forward += str[i].toUpperCase();
        
    }
}

for(let x = forward.length-1; x >= 0;x--){
    
    backward += forward[x];
}



if(backward === forward)
   return true;
  
else 
   return false;
}



palindrome("eye");

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/javascript-algorithms-and-data-structures-projects/palindrome-checker/

1eyeforof1eye is not the same as eye1forofeye1

If you read the instructions, you are supposed to keep all alphanumeric characters.

Ah I see thats F***** stupid… I checked for just letters! I did read the instructions btw H**

The third sentence of the instructions:

Note

You’ll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything into the same case (lower or upper case) in order to check for palindromes.

mdavis16 pls what is the code that solved this challenged…i am stucked

You can also use this code.

function palindrome(str) {
  return str.replace(/[\W_]/g, '').toLowerCase() ===
         str.replace(/[\W_]/g, '').toLowerCase().split('').reverse().join('');

}

function palindrome(str) {
let strconverted = str.replace(/[^A-Za-z0-9]/g, ‘’).toUpperCase()
return(!strconverted.split(’’).filter((val,ind)=>val!==strconverted.split(’’).reverse()[ind]).length)
}

What I came up with. I don’t know about performance though.

// JavaScript Algorithms and Data Structures Projects: Palindrome Checker

function palindrome(str) {

  return str.toLowerCase().match(/[A-Za-z0-9]/g).join('').split('').every((x,idx,arr) => {
    return (x === arr[arr.length-1 - idx])
  })

}

console.log(palindrome("A man, a plan, a canal. Panama"));