var inputArr = [{
name: "Smith",
points: 50
},
{
name: "Rock",
points: 27
},
{
name: "John",
points: 50
},
{
name: "Rock",
points: 800
},
{
name: "Smith",
points: 20
},
{
name: "John",
points: 80
}]
outputArr = {
"Smith" : 70,
"JOhn" : 130,
"Rock" : 827
}
name 应该是唯一的,并且应该合并唯一的名称点。例如:我们有 2 个史密斯,它们的点数分别为 50 和 20。所以结果应该是 {"smith" : 70}
相关分类