Use reduce instead of forEach for clarity

The purpose here is to accumulate, not just iterate for side effects.