I have this array of objects:
[
{
day: 1,
status: red,
count: 3
},
{
day: 1,
status: blue,
count: 5
},
{
day: 2,
status: red,
count: 10
},
{
day: 2,
status: blue,
count: 1
}
]
I want to re-factor this array into a new array and group by the day
value:
[
{
day: 1,
statusSummary: [
{
status: red,
count: 3
},
{
status: blue,
count: 5
}
]
},
{
day: 2,
statusSummary: [
{
status: red,
count: 10
},
{
status: blue,
count: 1
}
]
}
]
what is the most efficient way to do this?