Mutations Challenge — My code not qualified

Mutations Challenge — My code not qualified
0

#1

Tell us what’s happening:

I think it’s the same but it does not work.
My code will not pass the mutation(["hello", "hey"]); condition.

Your code so far

function mutation(arr) {
// My Code
//   var wCheck = arr[1].toLowerCase();
//   for(var i=0; i<arr[1].length; i++){
//     if(arr[0].toLowerCase().indexOf(wCheck[i]) == -1){
//        return false;
//      }
//     return true;
//   }
  
// fCC Code
  var test = arr[1].toLowerCase();
  var target = arr[0].toLowerCase();
  for (i=0;i<test.length;i++) {
    if (target.indexOf(test[i]) === -1)
      return false;
  }
  return true;
}

mutation(["hello", "hey"]);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36.

Link to the challenge:


#2

Because your return true is inside the for loop, you always return either true or false on the first letter of test.