Check for Palindromes - What's wrong with my code?

Tell us what’s happening:

Your code so far

str = str.replace(/[\W_]/g, '');
  var newStr = [];
  newStr = str.split('').join('');
  var newArray = [];
  newArray = str.split('').reverse().join('');
  if (newArray === newStr) {
  return true;


Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6.

Link to the challenge:

Recall that strings are immutable. Your toLowerCase lines aren’t doing what you think they are.

So, I see two issues, and the best (most precise) place to find the answer is the Syntax section of the MDN Javascript reference. It may seem intimidating at first, but it does explain exactly what is happening. Before I got more familiar with Javascript, I would first check out W3Schools’ Javascript reference. Their demo lets you mess around with it - no better way to learn programming than breaking something over and over :slight_smile: You can google search your way there, or use the search function within the link to the W3 site I provided.

The specific MDN links you need to read are: