my rule for .reduce(): only use it when the result has the same type as the items and the reducer is associative, like
.reduce((a, b) => a + b, 0)
summing some numbers
multiplying some numbers
building up a list or object
just about anything else (use a loop)
-
-
Never write OCaml
-
I don't plan on it lol
- 1 more reply
New conversation -
-
-
In my opinion the second option you listed in that example is a lot easier to read, but maybe I'm just old ¯\_(ツ)_/¯
-
Yeah and it can be made even more readable by removing the variable since it's just passed to the function directly
- 2 more replies
New conversation -
-
-
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Good hill.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
he/him 