Check for Palindromes Problem

Hi Everyone,
May I know where I am going wrong?

Your code so far

function palindrome(str) {
  var newStr = str.toLowerCase().replace(/[\W_]/g, "");
  var array = [];
  var newArray = [];
  array = newStr.split("");
  newArray = array.reverse("").join("");
  if (newArray == str){
     return true;
  else {
    return false;


Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36.

Link to the challenge:

You’re comparing newArray, which is actually a string, to the original input. Instead, you want to compare it to newStr.

Thank you for the reply. But its working fine for the “eye” but it is showing false when “_eye”. So there is problem in removing special characters or space or alphanumeric value.

It works fine for “eye”, because if str is “eye” and newArray is the reverse string of “eye”, so they are equal. You are comparing the wrong variables. Do as @sa-mm suggested and you will pass the challenge.