# Mutations freeCodeCamp Help needed

Tell us what’s happening:

``````function mutation(arr) {
var str = arr;
var main = arr;
var arr1 = [];
arr1 = arr.split("");
//return arr1;
var arr2 = [];
arr2 = arr.split("");
var count1;
var count2;
for(i= 0 ; i<arr.length;i++){
if((arr1[i] !== arr2[i])){
count1++;
}
}

for(i= arr.length; i >0;i--){
if((arr1[i] !== arr2[i])){
count2++;
}
}
if(count1 > 0 || count2 > 0){
return true;
}else {
return false;
}
}

mutation(["hello", "neo"]);
``````

Your Browser User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:59.0) Gecko/20100101 Firefox/59.0`.

https://www.freecodecamp.org/challenges/mutations

What improvements do i have to make ??

Can you explain to us the algorithm you figured out that you based your code on? You do not seem to have a grasp on the actual steps it would take to solve the challenge.

You should use the String.prototype.indexOf() function, it helps finding a char in a string.
And as said @RandellDawson, use comments to explain what the code is doing comparing every word of the two words

That is not an algorithm. Plus, you don’t care if arr has characters that are not in arr. You only need to make sure the all the characters in arr are present in arr. For example, the following should result in true.

``````mutation(["abcdefghijklmnopqrstuvwxyz", "k"]);  // true because all the characters in the second element (i.e. "k") are present in "abcdefghijklmnopqrstuvwxyz"
``````

but the following should not:

``````mutation(["hot", "abcdefg"]); // false because at least one of the second element's characters are not present in the word "hot".
``````

i have used substr() method and it also doesn’t help me i worked out for all except three test cases. P.S . I am trying to approach in a different way. Okay, I see the problem here,

you only check if char in arr1 are equal to char in arr2 one by one (first char equals first char, second char equals second char, …)
You need to check if first char of arr2 is equal to any char of arr1 (using indexOf will help for this)