# Mutatis Mutandis in Mutations

Tell us what’s happening:
Hi,

I think I need a bit of proof reading or logic check from someone. I can’t find any difference between mine and the Solution no 1 of this challenge but I know for sure that the Solution no 1 works with all the test arrays provided while mine fails with the [“hello”, “hey”] and similar but seems to work with the others.
My loop return the correct index -1 but does not return false (please see screenshots)
Any nudge will be appreciated
Thank you

``````
function mutation(arr) {
let newArr0 = arr[0].toLowerCase();
let newArr1 = arr[1].toLowerCase();
for (let i = 0 ; i < newArr1.length; i++){
return newArr0.indexOf(newArr1[i]) < 0 ? false : true;
}
}

console.log(mutation(["hello", "hey"])) //true
console.log(mutation(["hello", "heypgtvmjesrtpomrptyobmrtyopbentyop"])) //true
console.log(mutation(["date", "ert"])) //true
console.log(mutation(["hello", "yhey"])) //false
``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36`.

Challenge: Mutations

when your code meets a return statement it stops and return a value: your loop never go after first iteration

Hi,

thank you, I thought about it but then why the solution no1 is right?
Isn’t the return statement in a loop as well?

I may have missed some important information somewhere#
L

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

you have only one return statement inside the for loop, and it is executed only in a specific case: this is because once you know that there is one letter that make the condition false, there is no sense in continuing to check
the other return statement is after the loop

Ok, thank you.
My mistake was the statement in the non Conditional (Ternary) Operator :
(newArr1[i] < 0)) instead of (newArr1[i]) < 0)
In the Ternary operator, well I don’t know if you can use it in this situation

Thank you again