Iterate over array with reduce()