Unable to pass a specific test case for the Paindrome checker. I tested the logic outside freecodecamp with the same phrase and I am getting expected results

Tell us what’s happening:
Describe your issue in detail here.
I have one test case that is failing, but when I try testing outside of the freecodecamp test solution, with the same word, I am getting the expected response. I am not able to see an issue and hoping if maybe someone takes a look they can help me identify the issue with the logic

   **Your code so far**

function palindrome(str) {

var count = 0;
var testString = str.replaceAll(/[*_#\,.()-:/|]/g, "").replaceAll(" ", '').trim();


var word = testString.toLowerCase();
var arrayLength = word.length;
var i;

for (i = 0; i < arrayLength; i++) {
 if (word[i] == word[arrayLength - (i + 1)]) {
   count = count + 1;
 }
}

if (count == arrayLength) {
 return true;
}
else {
  return false;
}


}

palindrome("1 eye for of 1 eye.");
   **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36

Challenge: Palindrome Checker

Link to the challenge:

You mean you have a return for this string: ‘false’ somewhere?
I just run your solution with https://onecompiler.com/
and:

console.log(palindrome("1 eye for of 1 eye."));//true

I do have a return for false which is working for all other test cases but this one.

I actually tested this on a different platform but not running it as a function and was getting the results that the phrase “1 eye for of 1 eye.” is not a palindrome.

Its technically the same logic, not sure why it is failing for this specific phrase. I can’t tell what is wrong with the logic.

But I do see it is returning true using the Onecompiler, so I will try to debug it on there.

Did you try Python Tutor? It executes code line by line, maybe it wiil be more effective environment to identify your issue?

Well, maybe the last advice about Python Tutor was not the best… I tried to run your code there and it gives me Type Error… about replaceAll.
My suspicion that Python tutor has some unsupported features for JS.

I think I found some issues.
Here is the test of your regexp

let str = "1 eye for of 1 eye."
let testString = str.replaceAll(/[*_#\,.()-:/|]/g, "").replaceAll(" ", '').trim();

console.log(testString)//eyeforofeye


let str2 = "My age is 0, 0 si ega ym."
let testString2 = str2.replaceAll(/[*_#\,.()-:/|]/g, "").replaceAll(" ", '').trim();

console.log(testString2)//Myageissiegaym

I think your regexp deleting numbers from string, and you need to refactor your regexp.
Also, side note: your defining of TestString is a long and complex line of code, it’s uneasy to analyze it. Maybe add some comments or decompose it for the sake of readability?

The dash has a special meaning in character class, put it as first or last to avoid that special meaning
(The part )-: means all the characters from ) to :)

thank you, I was able to figure out the issue was with my regExp, and was able to update it and am now passing all test cases

thank you, yes the issue was with my regexp. I have updated it and am getting the correct results now

Would you be so kind to provide your final regexp? I’ ve just solved this challenge yesterday and i wanna to compare it with my solution.

yes sure

this was what i ended up using:

var testString = str.replaceAll(/[-*_#,.():/|]/g, “”).replaceAll(" ", ‘’);

You can combine those two replaces, you know?