CodePudding user response:
Var Bobby=[{Itme: "aaaa", Score: 56},
{Itme: "BBBB", Score: 94},
{Itme: "CCCC", Score: 87}
];
Var sum=Bobby. Reduce ((s, v)=& gt; S + v. core, 0);
Alert (sum/Bobby. Length);
CodePudding user response:
First, you use of array for... Of and entries () method is not very appropriate entries () method is generally used for object for the key and the value of the array key is the subscriptThe implementation of the way) you want such a
Const arr=[
{Item: "English", Score: 70},
{Item: "Math", Score: 92},
{Item: "Chinese", Score: 85},
]
Let count=0;
for(var i=0; I & lt; Arr. Length; I++) {
The count +=arr [I] Score
}
The console. The log (count);
CodePudding user response:
//this is an array, you have to traverse theBobby. Foreach (function (v) {
The console. The log (v.I tem, v. core)
})