When you map collections, you always end up with the same type of collection with the same number of values. When you iterate over every value in the collection and produce something that's not a mapped collection, it's called a reduction. Filtering is a type of reduction, for example, but sometimes, you need to produce noncollection values from collections.
If you need to produce another collection, combining filter()
and map()
is usually the right answer. You can compose your filter()
and map()
calls using concise and easy to read iteratee functions. When you need to produce a simple value, the reduce()
method is there for you.