I'm having trouble solving this issue, this is my array of objects
gamesAndChoosenNumbers: [
{
choosenNum: '15',
count: 10,
game: 'AB',
gameCode: 'double',
},
{
choosenNum: '15',
count: 5,
game: 'AB',
gameCode: 'double',
},
{
choosenNum: '16',
count: 20,
game: 'AB',
gameCode: 'double',
},
{
choosenNum: '16',
count: 20,
game: 'AB',
gameCode: 'double',
},
{
choosenNum: '16',
count: 10,
game: 'AB',
gameCode: 'double',
},
{
choosenNum: '150',
count: 10,
game: 'SUPER',
gameCode: 'super',
},
{
choosenNum: '150',
count: 10,
game: 'SUPER',
gameCode: 'super',
},
{
choosenNum: '155',
count: 20,
game: 'SUPER',
gameCode: 'super',
},
{
choosenNum: '155',
count: 20,
game: 'SUPER',
gameCode: 'super',
},
{
choosenNum: '200',
count: 10,
game: 'BOX',
gameCode: 'box',
},
{
choosenNum: '200',
count: 10,
game: 'BOX',
gameCode: 'box',
},
{
choosenNum: '155',
count: 20,
game: 'BOX',
gameCode: 'box',
},
];
so I want to reduce this array based on the choosenNum and game values and merge them and replace the count value with all of the other same objects **count'**s sum,
the result I'm exoecting to get is this