Let's say I have an array of objects that contain information about all the exams submitted during a period of time. It's structure's like this:
[
{ 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',
]
What I need is to ignore the date value and just calculate the average grade of each student and get a simple array like this:
[9, 6.5, 5]
Now let's say I want the array to follow a specific order so how can I rearrange it following this order: Freddy -> Jose -> Daniel ?
It seems kind of weird but I kind of need the output to be like this in order to use it as a dataset for Chart.js later on.