implementation of _.reduce done using _.each