Here is an example of an array:
[
{date:'27-06-2021',name:'John Doe',count:2},
{date:'29-06-2021',name:'John Doe',count:1},
{date:'29-06-2021',name:'George Newman',count:1},
]
I am looking to reformat this array into a new structure where the names become keys and the counts add up based on the dates.
The desired outcome should look like this:
[
{date:'27-06-2021',John Doe:2,sumCount:2},
{date:'29-06-2021',John Doe:1,George Newman:1,sumCount:2},
]
Is there a way to achieve this transformation? Any suggestions would be appreciated. Thank you!