I have an array like the following, that I will fetch from MongoDB:
[
{date: '2019-10-05', score: 3},
{date: '2019-10-05', score: 5},
{date: '2019-10-06', score: 4},
{date: '2019-10-06', score: 1},
]
I need to make a new array to look like the following:
[
{date: '2019-10-05', score: [3,5]},
{date: '2019-10-06', score: [4,1]}
]
Basically grouping the scores into the same arrays based on the date attribute. Any kinds of advice to achieve this is appreciated.