Eric Elliott, thanks for the great post!
I’m learning functional programming. And it’s really a fascinating world. And we all have heard many times that mutation, i.e. reassigning different values to the same variable is a bad thing, in general. And it’s bad for several reasons. In your function
reduce you’ve mutated your variable