Mutations Challenge Help

Mutations Challenge Help


I’m having a little trouble with the Mutations challenge and welcome any help. I have managed to satisfy all of the requirements except for the first one.

I’m not sure what I’m missing here…

Thanks in advance


Currently, your for loop is set up to loop through each character of the string. You assign testVal the result of the indexOf for current character in the string. You check whether testVal is greater or equal to zero and increment a if it is true. All these steps are fine.

The problem is the line after your if else statements:

  return true;

For the test case of mutation([“hello”, “hey”]);, during the first iteration of the for loop, key[0] = “h”. Your testVal = 0, so your if statement true block increments a by one. And then you suddenly return true which sends this value back to the call function and never finishes iterating through the rest of the array.

You do need to return true at some point, but you need to figure out when and where that should be. The same thing goes with your return false statement at the very end of the function.

NOTE: It is much easier for us to help you with code if you copy/paste your code into a forum post instead of putting a screen shot…