Mutations - Not able to solve the last subchallenge

Tell us what’s happening:
The last subchallenge which says mutation([“voodoo”, “no”]) is returning true. The o is getting matched twice. I am still not able to figure out where indexOf() comes handy here. It is given among the ‘helpful links’.

Your code so far

function mutation(arr) {
  var str1=arr[0].toLowerCase();
  var str2=arr[1].toLowerCase();
  var arr1=str1.split('');
  var arr2=str2.split('');
  var match=0;
  for(var i=0;i<arr1.length;i++)
    {
      for(var j=0;j<arr2.length;j++)
        {
          if(arr2[j]===arr1[i])
            match++;
          if(match===arr2.length)
           break;
        }
      
    }
  if(match===arr2.length)
    return true;
  else
    return false;
}

mutation(["voodoo", "no"]);

Your browser information:

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

Link to the challenge:

There is a very simple solution to this algorithm. It involves the methods these two methods. For this solution, you can use your first four lines of code where you declare your variables except for your variable named match.


Also here’s a hint for your solution above. Instead of manually checking each item to see if they match in the array with the for loop, try seeing if the item is included in the array (How would one check to see if an item is included in the array? wink wink).