Here is the JSON data I am working with:
[{
"semester":"1",
"classification":"Excellent",
"schoolYear":"2018"
},
{
"semester":"2",
"classification":"Intermediate",
"schoolYear":"2018"
},
// More JSON data...
]
I need a function to transform this data into the following format:
[
{
schoolYear: '2018',
semesters: [
{
Excellent: 2,
Good: 0,
Intermediate: 0,
Average: 0,
Weak: 0,
Fail: 0
},
{
Excellent: 0,
Good: 0,
Intermediate: 1,
Average: 0,
Weak: 0,
Fail: 0
}
]
},
{
schoolYear: '2017',
semesters: [
// More formatted data...
]
}
]
In essence, the function should output an array where each element has information for different school years and their corresponding semesters. Thank you in advance for your help! You can access and modify the code in this codesandbox demo here. Have a great day!