练习1:求数组中所有元素的和 var arr1 = [10, 20, 30, 40, 50]; var sum = 0; for (var i = 0; i < arr1.length; i++) { sum += arr1[i]; } console.log(sum); 练习2:求数组中所有元素的平均值 var arr2 = [1, 2, 3, 4, 5]; var sum2 = 0; for (var i = 0; i < arr2.length; i++) { sum2 += arr2[…