loading
index.js
1
2
3
4
5
6
7
8
9
10
11
const myArr = [1, 2, 3, 4, 5];


// Click run to run this you should get 15, 5 + 4 + 3 + 2 + 1
// Try changing the acc + x to multiply x and acc.
// also try changing the initial value 0? What happens?
// do you understand why the result changes?
const result = myArr.reduce((acc, x) => acc * x, 1);


console.log(result)
Fetching token