9951 explained code solutions for 126 technologies
[1, 2, 3, 4].reduce((total, x) => total + x)ctrl + cyoutubegithub
[1, 2, 3, 4].reduce((total, x) => total + x)
[1, 2, 3, 4]
test array to get the sum for
.reduce(
executes specified function for each element, docs
(total, x)
each element of an array x will be added to total variable
x
total