Looking to alter an array before grouping it by a certain value.
This is the initial array:
[
{
name: 'BoxOne',
count: 3
},
{
name: 'BoxTwo',
count: 2
},
]
I want to modify it based on the count value in each object. For example, if count 3 + 2 = 5, then the object should appear in the array accordingly.
Which function can I use to get an output array like this?
[
{
name: 'BoxOne',
count: 3
},
{
name: 'BoxOne',
count: 3
},
{
name: 'BoxOne',
count: 3
},
{
name: 'BoxTwo',
count: 2
},
{
name: 'BoxTwo',
count: 2
},
]