đź”— Understand Javascript Array Reduce in 1 Minute
This really helped me "get" array.reduce:
"Everybody knows what looping over a collection is. But do you know what reducing a collection means? No? Are you sure?" "It sounds scary. But it is in fact pretty simple. You do it all the time. Here. Let me show you an example:"
var total = 0;
var numbers = [1, 5, 7, 3, 8, 9];
for ( var i = 0; i < numbers.length; i++ ){
total += numbers[i];
}
"That’s it. You just reduced the “numbers” collection into the “total” variable. Pretty simple huh?"
It is now, yeah :)