Challenge Mutation - JS

Tell us what’s happening:
Hi everyone,
I’ve been trying to find out where was my mistake but I can’t find it.
My code works for every differents case except for :

mutation([“Hello”, “Hey”]);

The point of the exercise is to compare the first and second string inside the array and see if they have the same letters so far. If one is different it has to return false, otherwise, true.
Thank you for ur help !
Your code so far


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


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

Your browser information:

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

Link to the challenge:
I can’t since it’s my first post

Edit: correct some mistakes about my explaination

Yes that’s what I just noticed too.

I’m still trying to understand why it stops after the first character, I tried with differents value the problem never changed.

the issue is that once a return statement is executed the function stops, and you have two return statements in the loop of which one of the two is always executed

you need to rethink where to put the return statements

Ahaha thank you, it’s been like 30min that I’m looking at my loop or my condition trying to figure out what I did wrong there.
I did not notice the 2nd return wasn’t placed out of my loop.
Fresh eyes sometimes…

Thank you