Mutations and iterating through second array

Mutations and iterating through second array
0.0 0

#1

Tell us what’s happening:
Howdy! I have an array which I am trying to iterate through to see if the first array contains letters from the second array. It appears from console.log that for the second array, when I attempt to test the first letter, the loop stops and does not go on to the remainder of the characters within the second array. I’ve tried putting the return statement outside of the if condition, yet it still does the same thing. Just looking for a little guidance without peeking at any code if anyone can help.

Your code so far

function mutation(arr) {

for(i=0;i<arr[1].length;i++){
   var secondArray =arr[1].toLowerCase().split("");
   var firstArray =arr[0].toLowerCase();
  
    if(firstArray.indexOf(secondArray[i]) !== -1){
      console.log(secondArray[i]);
      return true;
    }
   return false;
  } 
  }

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

Your browser information:

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

Link to the challenge:


#3

Thanks for the help Juan! It totally worked!