JavaScript Algorithms and Data Structures Projects - Palindrome Checker

Tell us what’s happening:
Please why are this not being marked as correct;
1…palindrome("_eye") should return true .
2… palindrome("0_0 (: /-\ :) 0-0") should return true .

Your code so far

function palindrome(str) {
  str = str
  .toLowerCase()
  .replace(/[\W+]/g, '');
  let newStr = str.split("");
  let output = newStr
  .reverse()
  .join("");
  if(str == output){
    return true;
  }else{
  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/106.0.0.0 Safari/537.36 Edg/106.0.1370.52

Challenge: JavaScript Algorithms and Data Structures Projects - Palindrome Checker

Link to the challenge:

You aren’t removing non-alphanumeric characters

I remove non-alphanumeric character: “.replace(/[\W+]/g, ’ ')”

Not quite. At least one value that is not a letter or number is in that character class. The first test case you listed should show you what that bad character is

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