Would This palindrome function be considered correct?

Would This palindrome function be considered correct?
0

#1
function palindrome(str) {
  str = str.toLowerCase();
  str = str.replace(/[^a-z0-9]+/g, '');
  
  var reverse = str.split('').reverse().join("");
  return str == reverse;
}

I mean it works but when we were in school, we were told that for this to be considered legit, there shouldn’t be any occurrence of the word > reverse in the whole function


#2

If it’s for your school and your school told you not to use reverse(), then you need to refactor it to avoid that. Otherwise, it’s correct.