Please give a look! Noob utterly baffled by the behavior in this beginner algorithm 'Mutations'

Tell us what’s happening:
First I’d like to thank anyone taking the time and effort to parse through this mess of code. I am struggling to pass two of the tests in this algorithm challenge. The two failing tests that should pass are mutation([“Mary”, “Army”]) and mutation([“Mary”, “Aarmy”]). I cannot for the life of me understand why. Debugging as best I can tells me that my if statement is returning false on the third loop, at which point my indicator variable is [0,0,‘m’,‘r’,‘y’] and the letterToMatch variable is ‘m’. I’m really struggling to understand, but somehow:

arr[0].indexOf(letterToMatch)<0

or as I interpret:

[‘a’,‘a’,‘m’,‘r’,‘y’].indexOf(‘m’)

is returning a false negative when it should give an index value of 2?

Your code so far

function mutation(arr) {
  var firstWordSorted = arr[0].toLowerCase().split('').sort();
  var secondWordSorted = arr[1].toLowerCase().split('').sort();
  var indicator = secondWordSorted;
  
  for (i=0; i<secondWordSorted.length; i++) {
    var letterToMatch = secondWordSorted[i];
    console.log('ltm', letterToMatch, i, indicator);
    if (arr[0].indexOf(letterToMatch)<0) {
    	console.log('fail');
      return false;
    } else {
      indicator[indicator.indexOf(letterToMatch)] = 0;

    }
    if (indicator.reduce(function(a,b) {return a+b;}, 0) == 0) {
      console.log('pass');
      return true;}
  }
}

mutation(["Mary", "Aarmy"]);```
**Your browser information:**

Your Browser User Agent is: ```Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36```.

**Link to the challenge:**
https://www.freecodecamp.org/challenges/mutations

The problem is the line above. Think about what arr[0] is. Is this really the array on which you want to use indexOf?

Also, although it is not causing any issues, why did you think you needed to sort each array in the first two lines of your code? There is nothing about your solution that requires those arrays to be sorted.

Ohhhhh, I see what I did there! Thank you for your help, and also I very much appreciate you guiding me towards the solution without handing to me.

As for the sorting on the first two variable assignments, that was erroneous to the current solution. I started down a different path planning to compare the sorted arrays, but I ended up going this direction instead leaving those declarations as they were.