DEV Community

Discussion on: Explain REDUCE Like I'm Five

hasnayeen profile image
Nehal Hasnayeen

As the name suggest reduce decrease items in a collection and return just a single item. Lets say someone gave you a basket full of oranges. Now you're not interested in the basket and orange all you want is orange juice. So you use a reduce machine and dump all the orange in the machine and now the machine take a orange at a time and then peel the outer skins of the orange, remove any seeds and squeezes all the juices from it and collect it in a jar and keep doing it until no orange is left and you're left with a jar of orange juice. Bon Appétit