SPOILER ALERT FOR THOSE THAT HAVE NOT DONE THIS CHALLENGE YET!!!
This question is about the Basic Algorithim Scripting:Mutations challenge.
Can someone explain to me why we are checking to see if(target.indexOf(test)[i] === -1)… ?
Why are we looking for a -1?
The basic solution to this is:
function mutation(arr) {
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;
}
