September 2018
Intermediate to advanced
302 pages
7h 17m
English
It's time for a little challenge. Did you know that you can implement both map and filter with reduce?
Before we begin, let's do a quick recap how the filter function works:

Suppose we have a task collection and want to filter only tasks with type equal to 1, as follows:
const onlyType1 = task => task.type === 1
With a standard filter function, you would simply write the following:
tasks.filter(onlyType1)
But now, imagine there was no filter function and, so far, you only had reduce in your toolbox.
You could do the following:
tasks.reduce((acc,t) =>
Read now
Unlock full access