# Question about "Basic Algorithim Scripting: Mutations"

Question about "Basic Algorithim Scripting: Mutations"
0

#1

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;
}
``````

#2

I’ve edited your post for readability. When you enter a code block into the forum, remember to precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (`</>`) will also add backticks around text.

#3

The answer to your question is that `indexOf()` returns `-1` when the item is not found.

#4

@ArielLeslie you are the best meat popsicle here!