The problem with this is that it generates two intermediate arrays in the maps, then effectively drops them in the reduce. This may be inefficient.
I wish that JavaScript's map/filter/reduce functions returned lazy iterators, like in Rust, so that code like this doesn't produce intermediate arrays. Does anyone know of a library that provides this?