📜  累积和的 javascript 数组 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:41.982000             🧑  作者: Mango

代码示例1
const accumulate = arr => arr.map((sum => value => sum += value)(0));

// Example
accumulate([1, 2, 3, 4]);   // [1, 3, 6, 10]
// 1             = 1
// 1 + 2         = 3
// 1 + 2 + 3     = 6
// 1 + 2 + 3 + 4 = 10