I have an object that contains duplicate id
properties and I want to reduce them to one array for each. I only figured out a way to find unique id
s, but how can I concat the name
attribute?
const x = [
{id: 1, name: 'green'},
{id: 2, name: 'red'},
{id: 1, name: 'blue'}
]
Desired result:
[
{id: 1, name: 'green, blue'},
{id: 2, name: 'red'}
]