JavaScript Mutations| code executes right for all. Not passing the challange (possible bug)

JavaScript Mutations| code executes right for all. Not passing the challange (possible bug)
0

#1
var count = 0;

function mutation(arr) {
  var arrLength = arr.length;
  for(var i=0;i < arr[1].length;i++){
    if (arr[0].toLowerCase().indexOf(arr[1][i].toLowerCase()) !== -1){
      count +=1;
    }
  }
  if (count == arr[1].length){
    return true;}
  else{
    return false;
  }
}

mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]);

I get the correct result (true or false) for all the tests(see example above), but they will remain a red X :frowning:
I see nothing wrong in my code , it checks out for everything, why then, can’t I pass the challenge?


#2

I just figured out that it let’s me continue only if i put the “count” variable inside the for loop.
Can anyone tell me why this is ?


#3

The tests reuse the variables in the global scope. The changes to their value are carried over to the next text (which shouldn’t happend)