← Back to challenges

Get Students with Names and Notes Average

JavaScriptHardarraysobjects

Instructions

Create a function that takes an array of objects like { name: "John", notes: [3, 5, 4]} and returns an array of objects like { name: "John", avgNote: 4 }. If student has no notes (an empty array) then let's assume avgNote: 0.

Examples

[
  { name: "John", notes: [3, 5, 4]}
] ➞ [
  { name: "John", avgNote: 4 }
]

Notes

Try doing it with an arrow function.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.