Hello and thanks in advance for your help.
I am failing 2 out of the 13 tests, and I can’t figure out how to fix my code to pass these 2 as well.
Thanks,
Shawn Wright
// Failed: palindrome("A man, a plan, a canal. Panama") should return true.
// Failed: palindrome("My age is 0, 0 si ega ym.") should return true.
function palindrome(str) {
let tempStr = str.replace(/[^\p{L}\d]/gu, '');
let newStr = tempStr.split("").reverse().join("");
if(newStr === tempStr) {
return true;
} else {
return false;
}
}
palindrome("eye");
// I also tried reg. expr. for tempStr = str.replace(/[\W_]/g, '');
// I also tried reg. expr. for tempStr = str.replace(/[^A-Za-z0-9]/g, '');
Challenge: JavaScript Algorithms and Data Structures Projects - Palindrome Checker
Link to the challenge: