I have an array of objects in JavaScript that looks like this:
[{
day : "August 30th",
id: 1,
message : "lorem ipsum1"
},{
day : "August 30th",
id: 2,
message : "lorem ipsum2"
},{
day : "August 31th",
id: 3,
message : "lorem ipsum3"
}];
Now, I want to group these objects by date and restructure them into a new object as shown below:
{
"August 30th": [{
day : "August 30th",
id: 1,
message : "lorem ipsum1"
},{
day : "August 30th",
id: 2,
message : "lorem ipsum2"
}],
"August 31th": [{
day : "August 31th",
id: 4,
message : "lorem ipsum3"
}]
}
Can anyone recommend the best lodash method to achieve this transformation?