title: How to find inside an array of objects the object that holds the highest value?
body: <p>I have an array that holds several objects named student, each object student has several properties, one of which is an array named grades. </p>
  
  <p>I need to create a function that loops through the student's array and finds which student object has the highest grade inside its grades array.</p>
  
  <p>At the moment I am able to find the highest score, but was not able to understand how to trace back to which student it belongs to. </p>
  
  <p>Here is a snippet of how the function looks like:</p>
  
  <pre><code>function bestStudent() {
      var bestGrade = 0;
      var student;
      for(i=0; i &lt; studentArr.length; i++) {
          var student = studentArr[i];
          grades = student.grades;
          for(g = 0; g &lt;grades.length; g++){
              if(grades[g] &gt; bestGrade) {
                  bestGrade = grades[g];      
              }
          }
  
      }    
  }
  </code></pre>