Check for palindromes challenge

https://www.freecodecamp.com/challenges/check-for-palindromes#?solution= function%20palindrome(str)%20{ %20%20%2F%2F%20Good%20luck! %20%20str.replace%20(str.toLowercase())%3B%0A%20%20var%20array%20%3D%20str.split(%22%22)%3B%0A%20%20%20array%3Darray.reverse()%3B%0A%20%20var%20string%3Darray.join(%22%22)%3B%0A%20%20%0A%20%20%0A%20%20if(str%3D%3Dstring)%0A%20%20%20%20%7B%20%20return%20true%3B%7D%0A%20%20else%20%7B%0A%20%20%20%20return%20false%3B%0A%20%20%7D%0A%0A%7D%0A%0A%0A%0Apalindrome(%22eye%22)%3B%0A

function palindrome(str) {
// Good luck!
str.replace (str.toLowercase());
var array = str.split("");
array=array.reverse();
var string=array.join("");

if(str==string)
{ return true;}
else {
return false;
}

}

palindrome(“eye”);

what’s wrong with my code? please can someone help me out?

String.replace() doesn’t work the way you’re trying to use it, but you’ve got the right idea elsewhere. Try method chaining:

var newString = str.toLowerCase().split("").reverse().join("")