DEV Community

loading...

Discussion on: Why I don't like reduce

Collapse
tkdodo profile image
Dominik D Author

yes, summing two numbers is a classical example for reduce. It's actually reasonable because it really "reduces" the input into one value. I still prefer to use a util function for readability, like sum(numbers). Can be taken from lodash, but can also be just my own util that implements it with reduce. The name alone is worth the abstraction that I don't have to read reduce a bunch of times and have to grasp the implementation :)