JavaScript Algorithms and Data Structures Projects - Palindrome Checker

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/ Safari/537.36

Challenge: JavaScript Algorithms and Data Structures Projects - Palindrome Checker

Link to the challenge:

It looks like the test is calling function palindrome(...) but your function has a different name. Hope this helps

Hi, thanks for the quick answer, but I see two identical names ‘checkPalindrome’…
Do I miss something?

Hi there. If you go to the assignment and look at tests it will run, it is calling the function with the name palindrome().

For example…
Waiting:palindrome("A man, a plan, a canal. Panama") should return true.

Your function is called checkPalindrome(). If you change the name of your function to palindrome() the tests will be able to run correctly.
Also i would remove your last line which is a call to checkPalindrome() Bc the tests are very specific.

I hope this helps

1 Like

Ok, it works now. Thank you very much for your support and your patience.

1 Like