📅  最后修改于: 2022-03-11 15:01:12.156000             🧑  作者: Mango
var stars = [0, 0, 2, 3, 5],
count = 0,
sum = 0;
stars.forEach(function(value, index){
count += value;
sum += value * (index + 1);
});
console.log(sum / count);