Check for Palindromes help?

Check for Palindromes help?
0

#1

Tell us what’s happening:
I don’t understand why this code is not working. Any help would be appreciated.

Your code so far

function palindrome(str) {
  // Good luck!
  var array = [];
  var str1 , str2;
  str1 = str.replace(/[\W_]/g,"");
  str2 = str1.toLowerCase();
  array = str.split('');
  for(var i=0;i<array.length/2;i++){
    if(array[i]!==array[array.length-i-1]){
      return false;
    }
  }
  return true;
}



palindrome("_eye");

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36.

Link to the challenge:


#2

Hint: Why did you create str2 if you are not going to use it?


#3

A stupid mistake. Thank you.