Maybe, the (a, b) => ... notation was confusing — it kinda implies that a and b are array values, while actually a is the accumulator and b is the current value.
(a, b) => ...
a
b
So nowadays I define reduce fn params as acc and curr:
acc
curr
[ /**/ ].reduce((acc, curr) => acc + curr.data, 0)
Excellent thought. I'll adjust my code this way in the future!
I think I just said what this guy pointed out already. Haha
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Maybe, the
(a, b) => ...
notation was confusing — it kinda implies thata
andb
are array values, while actuallya
is the accumulator andb
is the current value.So nowadays I define reduce fn params as
acc
andcurr
:Excellent thought. I'll adjust my code this way in the future!
I think I just said what this guy pointed out already. Haha