title: How to use filter(), map() to work with values fo an array? JavaScript
body: <p>My task is:</p>
  <blockquote>
  <p>Implement the function duplicateStudents(), which gets the variable
  &quot;students&quot; and filters for students with the same matriculation
  number. Firstly, project all elements in students by matriculation
  number. After that you can filter for duplicates relatively easily. At
  the end project using the following format: { matrikelnummer:
  (matrikelnummer), students: [ (students[i], students[j], ... ) ] }.</p>
  <p>Implement the invalidGrades() function, which gets the variable &quot;grades&quot;
  and filters for possibly incorrect notes. For example, in order to
  keep a manual check as low as possible, the function should determine
  for which matriculation numbers several grades were transmitted for
  the same course. Example: For matriculation number X, a 2. 7 and a 2.
  3 were transmitted for course Y. However, the function would also take
  into account the valid case, i. e. for matriculation number X, once a
  5,0 and once a 2,3 were transmitted for course Y.</p>
  <p>In this task you should only use map(), reduce(), and filter(). Do not
  implement for-loops.</p>
  </blockquote>
  <pre><code>function duplicateStudents(students) {
    return students
      // TODO: implement me
  }
  
  function invalidGrades(grades) {
    return grades
      .map((s) =&gt; {
        // TODO: implement me
  
        return {
          matrikelnummer: -1/* put something here */,
          grades: []/* put something here */,
        };
      })
      .filter((e) =&gt; e.grades.length &gt; 0)
  }
  </code></pre>
  <p>The variables students and grades I have in a separate file. I know it might be helpful to upload the files too, but one is 1000 lines long, the other 500. That’s why I’m not uploading them. But I hope it is possible to do the task without the values. It is important to say that the values are represented as an array<a href="https://i.stack.imgur.com/ea5pF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ea5pF.png" alt="enter image description here" /></a></p>