Our previous solution used forEach
and a globally available array that could be mutated from inside our function. We can improve upon this and create a function that is easier to maintain & test by swapping our forEach
loop for reduce
. By removing the global array and instead making getTasks
return a value directly we end up with a pure function.
This lesson video was updated!
In Array.prototype.reduce method, first parameter is accumulator and second one is currentValue, not previous and next.
These three vids were the absolute best intros to Recursion I've seen in my career; for the way I see programming anyway ☻
To me that seems like semantics.
Really valuable, thank you