I have a list of items with duplicate IDs and I want to merge them into one array for each unique ID. I have successfully found the unique IDs, but now I need help combining the names associated with those IDs.
const x = [
{id: 1, name: 'green'},
{id: 2, name: 'red'},
{id: 1, name: 'blue'}
]
Desired output:
[
{id: 1, name: 'green, blue'},
{id: 2, name: 'red'}
]