As a collapse and an array for a property to handle:
[ { key: 'black', value: [ '2', '3', '9' ] },
{ key: 'black', value: [ '1' ] },
{ key: 'gold', value: [ '2', '3' ] },
{ key: 'gold', value: [ '1' ] },
{ key: 'red', value: [ '9' ] },
{ key: 'white', value: [ '2', '3' ] },
{ key: 'white', value: [ '1' ] } ]
... at:
[ { key: 'black', value: [ '1', '2', '3', '9' ] },
{ key: 'gold', value: [ '1', '2', '3' ] },
{ key: 'red', value: [ '9' ] },
{ key: 'white', value: [ '1', '2', '3' ] } ]
... with javascript.
I feel that there should be a fairly simple way to do this using lodash or Array.reduce, but I cannot have my life determine how to do it.