Mutations Free Code Camp Challenge

Mutations Free Code Camp Challenge


Tell us what’s happening:

Your code so far

function mutation(arr) {
  var string1 = arr[0].toLowerCase().split('');
  var string2 = arr[1].toLowerCase().split('');
  for(i=0; i<string1.length; i++){
    if(string1.indexOf(string2[i]) !== -1){
        return true;
     return false;

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

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36.

Link to the challenge:


Do you have a specific question?


Yeah. Every condition except the first passes. Why?


Partly, because you only iterate through the string1 array, before you return either true or false. Once the return statement is executed, the function is immediately exited even if it is not finished iterating through the array. You need to modify your logic just slightly for it to work.

An extra hint, you should be iterating through string2 and checking if the string2’s current letter is in string1 and not the other way around.


Thanks! I figured it out with your help!