var arr1 = [10, 20, 30, 40, 50];
var sum = 0;
for (var i = 0; i < arr1.length; i++) {
sum += arr1[i];
}
console.log(sum);
var arr2 = [1, 2, 3, 4, 5];
var sum2 = 0;
for (var i = 0; i < arr2.length; i++) {
sum2 += arr2[i];
}
console.log(sum2 / arr2.length);
var arr3 = [1, 9, 3, 10, 3330, 32];
var max = arr3[0];
for (var i = 0; i < arr3.length; i++) {
if (max < arr3[i]) {
max = arr3[i];
}
}
console.log("最大值:" + max);
原文:https://www.cnblogs.com/jane-panyiyun/p/11924770.html