【发布时间】:2021-09-22 12:09:23
【问题描述】:
我有一组对象,我需要滚动它们并添加 Maria 和 Cristiano 的战斗胜利,最后我需要显示每个人赢得了多少 BattleWon,如示例所示
const array = [
{
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] ]
}
]
预期:
{
Cristiano: 0,
Maria: 2
}
【问题讨论】:
标签: javascript arrays