I have an array of objects. These objects have two props: property 'label' of type String and a prop 'detections' which is an Array. I need a functions that can group the objects of same label merging the relative arrays.
For instance:
const list = [
{ label: 'cat', detections: ['a','b'] },
{ label: 'horse', detections: ['c','d'] },
{ label: 'cat', detections: ['e','f'] }
]
Would become:
const result = groupMergeByLabel(list)
// value logged would be => [
{ label: 'cat', detections: ['a','b','e','f'] },
{ label: 'horse', detections: ['c','d'] }
]