Function palindrome

I have been trying this question for a while, I am not sure what is wrong with my code.
Odd number array with return true could not passed…

Shall I just go for split. reverse. join function then compare the two strings, instead of comparing arrays…

function palindrome(str) {
  // Good luck!

  str = str.replace(/[^a-zA-Z 0-9]+/g,'');
  str = str.toLowerCase();
  
  var arrNum = str.length;
  // make it int not flort
  var middlePoint = Math.floor (arrNum /2);
  var j = 0;

  
  while( j < middlePoint) 
  {  
    if (str [j] == str [arrNum -1 - j])
    {
          j++;
          
          //if array is odd number
          if (j == (arrNum -1-j))
           {
               return true;
           }
     } 
     else 
     {
         return false;
     }       
  }
  return true;

}

OH!!! thank you so much! I really need to be trained to be super careful - it to
ok me about 3 hours :joy:

I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.

Thanks a million . I woundered how to post codes :):slight_smile: