Imagine having a collection of objects that hold details about exams submitted over a period. Here is the structure:
[
{ name: 'Freddy', grade: 10, date: '20/07/2022' },
{ name: 'Jose', grade: 8, date:'20/07/2022' },
{ name: 'Freddy, grade: 8', date: '25/07/2022' },
{ name: 'Daniel', grade: 5, date: '21/07/2022' },
{ name: 'Jose', grade: 5 }, date: '22/07/22',
]
The goal is to disregard the dates and compute the average grade for each student, resulting in a simple array like this:
[9, 6.5, 5]
In addition, if there's a need to reorder the array to match the sequence Freddy -> Jose -> Daniel, how can that be achieved?
While it may seem unusual, this specific order is necessary for later use as a dataset in Chart.js.