Basic Algorithm Scripting - Mutations

Tell us what’s happening:
Describe your issue in detail here.
I was able to pass all of the tests except the very first one. I don’t know what makes the first test differ from all of the rest. I made the first array and the second array both lower case.

   **Your code so far**
function mutation(arr) {
 let firstArr = arr[0].toLowerCase();
 let secondArr = arr[1].toLowerCase();
for (let i=0; i< secondArr.length; i++){

if  (firstArr.indexOf(secondArr[i]) === -1){
return false;

}else{
 return true
}
}
}

mutation(["hello", "hey"]);
   **Your browser information:**

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36

Challenge: Basic Algorithm Scripting - Mutations

Link to the challenge:

The mistake you did, it haunts me like all the time)

Double-check your if…else logic

WHEN you wanna return true? You are doing it inside the loop now

1 Like

I just KNEW it was something simple like this! Thanks a bunch!

I don’t know if it is simple, for me logic errors are the most terrifying :upside_down_face: