Loved your Topic, even i am interested in .reduce()
The first Example will be hard for the starters to understand, So here's my Version!
var arr = [1,2,3,4,5];
arr.reduce(function(accumulator, nextValue){
return accumulator + nextValue;
});
This will generate the following result
accumulator nextValue returnedValue
1 2 3
3 3 6
6 4 10
10 5 15
And Hence the result will be 15
var arr = [1,2,3,4,5];
arr.reduce(function(accumulator, nextValue){
return accumulator + nextValue;
},10);
It will generate the following. Keep in mind, if the second parameter is passed then this is treated as the first value in the array
accumulator nextValue returnedValue
10 1 11
11 2 13
13 3 16
16 4 20
20 5 25
I hope you find my answer helpful, please do like and comment it gives me the confidence to be more helpful and innovative😇