Help with mutations challenge pls [Solved]

I think I have been looking at this for too long perhaps some fresh eyes, I know there are other streams with this issue but I dont want to look at them. My code passes all but the first green.

function mutation(arr) {
  var newArr0=arr[0].toLowerCase();
  var newArr1=arr[1].toLowerCase();
  for(i=0;i<newArr1.length;i++){
    if(newArr0.indexOf(newArr1[i])>-1){
      return true;
    }
    return false;
  }
}

I have tried various combinations of > < == >= -1, 0 and used the console to try figure it out but no joy!

You are VERY close.

Look very carefully at the test cases and think about why they are returning true or false. Think about the differences in each of the strings that gets passed as arguments. Don’t assume they are passing or failing because of what you think your code is doing…step through your own code with a pen and paper and figure out why your function returns true or false when it does.

You have 3 tiny changes to make and then it will pass…

If you get really stuck I can give more pointers.

1 Like

Thanks @JacksonBates I have solved it!

1 Like