配列の合計を求める
function sumArray(arr) {
return arr.reduce((a, b) => a + b);
}
使用例
let test = [3, 8, 2, 9, -8];
print(sumArray(test)); // 出力: 14
function sumArray(arr) {
return arr.reduce((a, b) => a + b);
}
let test = [3, 8, 2, 9, -8];
print(sumArray(test)); // 出力: 14