Let's say I got an Array below:
[
{ type: 'senior', schoolName: 'school-A', country: 'America' },
{ type: 'senior', schoolName: 'school-B', country: 'England' },
{ type: 'junior', schoolName: 'school-C', country: 'German' },
{ type: 'junior', schoolName: 'school-D', country: 'Italy' },
]
How can I convert the array above to an object as shown in below:
{
senior: {
America: 'school-A',
England: 'school-B'
},
junior: {
German: 'school-C',
Italy: 'school-D'
}
}
What is the syntactically cleanest way to accomplish this?
Thanks for any help!!