# Mutations - what I am missing?

Hello campers, I am working on Mutations challenge and it doesn’t work… I don’t want to look at the solution, can you help me, please?

This is my code with the comments:

``````function mutation(arr) {
var x = 0;
for (var firstArray= 0; firstArray < arr.length; firstArray++) {
for (var secondArray = 0; secondArray < arr.length; secondArray++)  {

x = arr[firstArray].indexOf(arr[secondArray]) !== -1;  // arr[firstArray] gets every letter of arr(0), then  .indexOf(arr[secondArray]) should get every letter of arr...
}
}
return x;
}

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

``````function mutation(arr) {
for (var firstArray= 0; firstArray < arr.length; firstArray++) {
for (var secondArray = 0; secondArray < arr.length; secondArray++)  {

x = arr[firstArray].indexOf(arr[secondArray]) !== -1;
}
}
return x;
}

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

Thank you.

You will have to change your code inside the for loops.
Basically the statement `x=arr[......` only checks if the firstArray letter is equivalent to the secondArray letter.

``````h.indexOf(h)!==-1 x=true
h.indexOf(e)!==-1 x=false
h.indexOf(y)!==-1 x=false
.
.
.
o.indexOf(h)!==-1 x=false
o.indexOf(e)!==-1 x=false
o.indexOf(y)!==-1 x=false
``````

calculating all these goes into vain because at the end `x` value depends only on the comparison of the last character from both the array elements which does not meet the logic of the program.

I know i have framed the answer very poorly but if someone could take a hint from my answer and explain it better i would be grateful to them !

function mutation(arr) {
var x = 0;//first you should arr and arr to a lowercase
for (var firstArray= 0; firstArray < arr.length; firstArray++) { //you don’t need to loop through arr
for (var secondArray = 0; secondArray < arr.length; secondArray++) {//just loop through arr

``````  x = arr[firstArray].indexOf(arr[secondArray]) !== -1;  //you must check arr[secondArray] in arr not arr[firstArray]
``````

newArr=newArr.concat(x);// you should add a newArr and push x to
}
}