I'm trying to group the follow array by id.
Ive tried using lodash, but my result is also duplicating id i.e "id":[6,6,6,6]
This is my existing array;
[
{
"nestedGroups": 64,
"id": 6
},
{
"nestedGroups": 27,
"id": 6
},
{
"nestedGroups": 24,
"id": 6
},
{
"nestedGroups": 69,
"id": 6
}
]
My expected outcome is to combine the nestedGroups into an array using the id as the key.
[
{
"nestedGroups": [64,27,24,69],
"id": 6
}
]