← Back to challenges

Get Student Top Notes

JavaScriptHardarraysobjects

Instructions

Create a function that takes an array of students and returns an array of their top notes. If the student does not have notes then let's assume their top note is equal to 0.

Examples

getStudentTopNotes([
  {
    id: 1,
    name: "Jacek",
    notes: [5, 3, 4, 2, 5, 5]
  },
  {
    id: 2,
    name: "Ewa",
    notes: [2, 3, 3, 3, 2, 5]
  },
  {
    id: 3,
    name: "Zygmunt",
    notes: [2, 2, 4, 4, 3, 3]
  }
]) ➞ [5, 5, 4]

Notes

  • Try it with Array.prototype.map and Array.prototype.reduce.
  • Alternatively use Math.max instead of Array.prototype.reduce.
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Which Number Is Not like the Others?