how
reduce
works in
JS
?
const initValue =
0
0
const values = [
3
3
,
5
,
1
,
4
,
2
]
const total = values.reduce((
acc
0
,
item
3
) => {
return
acc
+
item
}, initValue)
view source code on github