How to solve the Palindrome project


I dont seem to understand what I am doing wrong. The code does not get past the if statement. The else statement does not get executed. What am I doing wrong?

function palindrome(str) {
  var Str = str.toLowerCase();
    var strMatch = Str.match(/[a-z]|[0-9]/g);
  var strMatchRev = strMatch.reverse();
  for (var i = 0; i < strMatch.length; i++){
    if (strMatch[i] === strMatchRev[i]){
      return true;
      return false;


You actually have 2 different problems:

First, you need to review what Array.prototype.reverse() not only returns, but what it actually does to the original array. I think you will be surprised what your line below is actually doing:

 var strMatchRev = strMatch.reverse();

Once you get that figured out, you are going to want to review your if then logic with respect to the return statements. Remember, that once the return statement is executed, it completely exits out of the function even if the entire for loop has not been iterated through.


Thanks! I’ll look into that.