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++){
        forward += str[i].toUpperCase();

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

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


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:

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:


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

If you have a question about your own code, please use the Ask for Help button located on the challenge, so you will have your own topic so we can help you there. Plus, using the Ask for Help button automatically posts your code and a link to the challenge.

Thank you.

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()

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"));