Check for Palindromes input

Check for Palindromes input
0

#1

Tell us what’s happening:

My function works for most of the words like “eye” but whenever there’s a space or special character it fails can someone help me?

Your code so far

function palindrome(str) {
  var newString="";
  str=str.toLowerCase();
  for(var i=str.length-1;i>=0;--i)
    {
      newString=newString+str[i];
    }
  if(str.equals(newString))
  return true;
  
  return false;
}



palindrome("eye");

Your browser information:

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

Link to the challenge:


#2

You should remove the chars that are not letters or numbers. Check out the replace() function and regular expressions to find out how to remove non-alphanumeric chars from a string.