Mutations not returning correct value on one of the test cases

Mutations not returning correct value on one of the test cases
0

#1

I need some help, this is what i have, for some reason its returning mutation([“hello”, “hey”]) as true, all of the other cases are returning correctly though


function mutation(arr) {
var b = arr[1].toLowerCase();
var a = arr[0].toLowerCase();
for (i=0; i<b.length; i++) {
  if (a.indexOf(b[i]) === -1) {
  return false;
} else{
  return true;
    }
}
}
mutation(["hello", "hey"]);

Mutations(Spoiler: Solution)
#2

I moved your question to a new topic, because the other topic was for completed solutions.

It is more of a coincidence the other tests past, because your for loop only goes through one iteration before returning true or false. When a return statement is used, the value is returned and the function exits immediately regardless if the for loop has completed all iterations.

Your logic is structured perfect to find a false condition.

HINT: If your for loop completes without returning false, what does that mean you should do?