I was working on a story with a client that had to take a list of filters and intersect them.
Using uderscorejs and the reduce and intersect functions i implemented a fix. Below is an example implementation of said functions
val1 = _.reduce([1, 2, 3], function (v, a) {
return v + a;
});
After pushing this, I noticed not everyone was familiar with functional programming and found it taking a little bit longer to wrap their head around the code from a readability point of view
I decided to take a second dive but this time focus more on the readability.
val2 = _([1, 2, 3]).reduce(function (v, a) {
return v + a;
});
And the crowd went... no crowd... but in my head they cheered and bought me nachos!