title: Index of the largest float in the array
body: <p>How can I get the index of the largest element in the array of floats?</p>
  
  <p><code>[0.000004619778924223204, 0.8323721355744392, 0.9573732678543363, 1.2476616422122455e-14, 2.846605856163335e-8]</code></p>
  
  <p>Once I get this index, I then want to get the value of another array at this index.</p>
  
  <p>Let's call the second array:</p>
  
  <p><code>['a', 'b', 'c', 'd', 'e']</code></p>
  
  <p>When I ran the following, I got <code>'b'</code> instead of <code>'c'</code>.</p>
  
  <p>I iterated through the first array and made a map of the floats to the strings. Then I got the string at the the first element of the first array ( array of floats ) sorted.</p>
  
  <pre><code>//aInput in the array of floats.
  var emObj={};
  for(var i=0; i&lt;aInput.length; i++){
      emObj[aInput[i]]=['a', 'b', 'c', 'd', 'e'][i];
  }
  return emObj[aInput.sort()[0]];
  </code></pre>
  
  <p>I also tried a method where I iterated through the array of floats and stored the largest value in a variable. Then I'd do something like this:</p>
  
  <pre><code>return ['a', 'b', 'c', 'd', 'e'][aInput.indexOf(largestFloat)];
  </code></pre>
  
  <p>But neither of these worked. Always returning the wrong string.</p>