编辑代码

let arr = [1, 2, 3, 4, 5];
let total = arr.reduce((x,y) => x + y);
console.log(total)

let arr = [1, 2, 3, 4, 5];
let total = arr.reduce((x,y) => x + y,0);
console.log(total)