The palindromes aren't returning what they are suppose to

Hello there, My problem is that the palindrome(“My age is 0, 0 si ega ym.”),palindrome("_eye") and palindrome(“almostomla”) aren’t returning what they are suppose to return. I cant find the solution to the problem, can anyone help?

  **My code so far**

function palindrome(str) {
str = str.toLowerCase().replace(/\W_/g, '');;
for(let i = 0; i < str.length/2; i++){
  if (str[i] !== str[str.length - 1 - i]){
    return false;
  } else {
    return true;

  **Your browser information:**

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

Challenge: Palindrome Checker

Link to the challenge:

It seems you are only confronting first and last letter, not the whole word

“Match a character that is not a word character (not a-z,A-Z,0-9 or _) followed by an underscore character and replace it with empty string”

So _eye, nothing matches there

Also, two semicolons

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.