That's why it's important use well named variables, imagine that your first approach with reduce was this way: arr.reduce((accumulator, currentValue) => accumulator + currentValue);
arr.reduce((accumulator, currentValue) => accumulator + currentValue)
Much better, don't you think so? It's almost self explanatory...
This is still confusing to someone who has never worked with reduce(). But then makes explaining it a bit more easy.
reduce()
I'm pretty sure I would still have found a way to be confused by it, hahaha
But I do agree that clear naming goes a long way to help understand code.
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.
That's why it's important use well named variables, imagine that your first approach with reduce was this way:
arr.reduce((accumulator, currentValue) => accumulator + currentValue)
;Much better, don't you think so? It's almost self explanatory...
This is still confusing to someone who has never worked with
reduce()
. But then makes explaining it a bit more easy.I'm pretty sure I would still have found a way to be confused by it, hahaha
But I do agree that clear naming goes a long way to help understand code.