Palindrome checker quiz question

// running tests

palindrome(“1 eye for of 1 eye.”)
should return

I keep getting this message and the test fails, but according to the requirements of the quiz, and the definition of a palindrome, the string “1 eye for of 1 eye” is a palindrome (once all non-alpha characters are stripped away).

  **Your code so far**

function palindrome(str) {
//remove spaces
var stripped = str.replace(/[\d\W_]/g, '');
var str1 = stripped.toLowerCase().split(" ");

var str_concat = "";
for(let i = 0; i < str1.length; i++){
  str_concat+= str1[i];

var arr = str_concat.split("");
var revArr = str_concat.split("");
var f = 0;

if (arr.length == revArr.length)
  for(let i = 0; i < arr.length; i++){
    if( arr[i] != revArr[i]){
      f +=1;
if(f > 0){
  return false;
  return true;

  **Your browser information:**

User Agent is: Mozilla/5.0 (X11; CrOS aarch64 14324.62.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.77 Safari/537.36

Challenge: Palindrome Checker

Link to the challenge:

The beginning of the string starts with “1” and ends with “e” so I don’t see how this could be a palindrome.

" Note: You’ll need to remove all non-alphanumeric characters"

“1” is an alpha-numeric character so you don’t want to remove it.

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