I have looked through a lot of the answers here on StackOverflow but can't quite find what I'm looking for. I have an array of objects like
const arr = [
{id: 1, title: "Foo", time: "18:00"},
{id: 2, title: "Bar", time: "20:00"},
{id: 3, title: "Foo", time: "21:00"}
]
The output I'm looking for should be aggregated by the title
property of the objects in arr
, ie.
const output = [
{title: "Foo", i: [
{id: 1, time: "18:00"},
{id: 3, time: "21:00"}
]
},
{title: "Bar", i: [
{id: 2, time: "20:00"},
]
}]