Given an array of objects containing battle information for Maria and Cristiano, the task is to scroll through them and add up their battlesWon count. Finally, display how many battles each one won as demonstrated in the example.
const arrayOfBattles = [
{
id: '147acaa3-363c-4a28-af43-fcc035a1d500',
arena: 'Philippine Arena',
firstParticipant: {
address: '0x3ba59bcc1a02cb46e7de35fb0bacc860bf075661',
name: 'Cristiano',
battlesWon: 0
},
secondParticipant: {
address: '0x3ba59bcc1a02cb46e7de35fb0bacc860bf075644',
name: 'Maria',
battlesWon: 1
},
logs: [ [Object] ]
},
{
id: 'b2ef2d28-d84d-4cc9-946f-3d57b8ce05ab',
arena: 'Greensboro Coliseum',
firstParticipant: {
address: '0x3ba59bcc1a02cb46e7de35fb0bacc860bf075644',
name: 'Maria',
battlesWon: 1
},
secondParticipant: {
address: '0x3ba59bcc1a02cb46e7de35fb0bacc860bf075661',
name: 'Cristiano',
battlesWon: 0
},
logs: [ [Object] ]
}
]
Expected Output:
{
Cristiano: 0,
Maria: 2
}