title: Dealing with Nested Objects in Javascript -- Not totally Understanding Concept
body: <p>Still learning here. This one as simple as it seems, has beaten me up. I have managed to get the answer. But, when I do, I am getting more than one name coming out of my if statement. I used a new set to remove the duplicate names in the names array. But frankly, that seems lazy to me and I feel something can be done that is better.</p>
  <p>Can someone show me some ways I'm missing to better go through this problem? I tried flattening and that didn't work either. Thank you for your help!</p>
  <p><strong>Here are the directions given to me:</strong>
  Create a function <code>passingStudents</code> that accepts an array of student objects.
  It should iterate through the list of students and return an array of the names of all the students who have an average grade of at least 70.</p>
  <pre><code>function passingStudents(students) {
    const names = [];
      students.forEach(student =&gt; {
          student.grades.forEach(grade =&gt; {
        if(grade.score &gt;= 70) {
          names.push(student.name);
        }
      });
    });
    
    let uniqueChars = [...new Set(names)];
    
  
    return uniqueChars;
  }
  
  
  //Uncomment the lines below to test your function:
  
  var students = [
    {
      &quot;name&quot;: &quot;Marco&quot;,
      &quot;id&quot;: 12345,
      &quot;grades&quot;: [{&quot;id&quot;: 0, &quot;score&quot;: 65}, {&quot;id&quot;: 1, &quot;score&quot;: 75}, {&quot;id&quot;: 2, &quot;score&quot;: 85}]
    },
    {
      &quot;name&quot;: &quot;Donna&quot;,
      &quot;id&quot;: 55555,
      &quot;grades&quot;: [{&quot;id&quot;: 0, &quot;score&quot;: 100}, {&quot;id&quot;: 1, &quot;score&quot;: 100}, {&quot;id&quot;: 2, &quot;score&quot;: 100}]
    },
    {
      &quot;name&quot;: &quot;Jukay&quot;,
      &quot;id&quot;: 94110,
      &quot;grades&quot;: [{&quot;id&quot;: 0, &quot;score&quot;: 65}, {&quot;id&quot;: 1, &quot;score&quot;: 60}, {&quot;id&quot;: 2, &quot;score&quot;: 65}]
    }
  ];
  
  console.log(passingStudents(students)); // =&gt; [ 'Marco', 'Donna' ]
  </code></pre>