I have this array
bidsList = [
{
supplierName:'A',
awardedCapacity:5,
},
{
supplierName:'B',
awardedCapacity:10,
},
{
supplierName:'A',
awardedCapacity:5,
},
{
supplierName:'A',
awardedCapacity:3,
},
{
supplierName:'B',
awardedCapacity:5,
},
{
supplierName:'C',
awardedCapacity:2,
},
i need to have separete array where when i make the iteration throught this array i will calculate the total of all awardedCapacities where the supplier name is same
For example i should have array where i will have this output
let newArr = [
{
supplierName: 'A',
totalAwarded: 13,
},
{
supplierName:'B',
totalAwarded: 15,
},
{
supplierName:'C',
totalAwarded: 2,
}
]
because on previous array i had three objects where the supplierName was A and when i sum their awarded capacities i am geetting 13 in the other object with it's supplier name