DEV Community

Discussion on: What s wrong with Array.reduce ?

 
wulymammoth profile image
David • Edited

Fair points, but it's not "wrong". My intention was to set a floor, though, not explicitly stated. The initial value matters. Although, your suggestion is the same as mine, because your floor is -Infinity. To derive the min, we don't need an initial value at all -- it's optional. The only instance in which that wouldn't work is an empty array - sort of the case I was covering :)

Now, let's write some unit-tests to document :)