Tell us what’s happening:
I don’t know why this code is not working. In 'Visual Studio Code", it works perfectly… Can someone help me?
Your code so far
function checkPalindrome(string) {
string = string.replace(/[\W_]/gi, '').toLowerCase();
const len = string.length;
for (let i = 0; i < len / 2; i++) {
if (string[i] !== string[len - 1 - i]) {
return false;
}
}
return true;
}
// call the function
checkPalindrome("rAcE!?@ cAr!!!");
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36
Challenge: JavaScript Algorithms and Data Structures Projects - Palindrome Checker
Link to the challenge: