Get Students with Names and Notes Average

Published by Werdna in

Create a function that takes a list of dictionary like { name: "John", notes: [3, 5, 4]} and returns a list of dictionary like { name: "John", avgNote: 4 }. If student has no notes (an empty array) then avgNote is zero.

Examples

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

Notes

Round the avgNote to a whole number.

Watch a quick demo on how Edabit works.