I tried solving the palindrome checker code and all test cases pass except the one with the “0_0 ( : /-\ : ) 0-0” string. It says palindrome(“0_0 ( : /-\ : ) 0-0”) should return true` but why should it return true when it is not a palindrome. Shouldn’t it return false?
Your code so far
function palindrome(str) {
let regex=/[^.,_:\s]/gi;
let str1=str.match(regex).join().toLowerCase();
let newStr1=str.split("").reverse().join();
let str2=newStr1.match(regex).join().toLowerCase();
for(let i=0;i<str.length;i++){
if(str1[i]!==str2[i]){
return false;
}
}
return true;
}
palindrome("eye");
Challenge: JavaScript Algorithms and Data Structures Projects - Palindrome Checker