I agree your example is one where reduce is better expressed in other ways. But I think there's cases where reduce is the correct metaphor and the clearest construction:
const max = (numbers) => numbers.reduce((max, number) => number > max ? number : max);
I will never be convinced that a for loop is more readable than that (and map and filter aren't options for this type of computation)
I agree your example is one where
reduce
is better expressed in other ways. But I think there's cases wherereduce
is the correct metaphor and the clearest construction:I will never be convinced that a for loop is more readable than that (and
map
andfilter
aren't options for this type of computation)I almost always to write first argument as
prev
oracc
; therefore,About readability, I guess it depends on how you visualize.