I provide solutions that matter. With my strong background in Internet and Web, I've worked on challenging platforms and have created web applications that are used on a daily basis.
I have myself found .reduce to be very useful however, I think one must atleast put some time in naming the accumulator comprehensively so, it is self-evident what the list of items will be reduced to. Personally, in the first example, I would have named accumulator to be sum or total. In the second example, shortestWord. In the third (tricky) example, perhaps, reverseObject and, I would have defined reverseObject to be an object that has their keys / values swapped (as a comment).
However, like Ben said, this would definitely help JS developers to not shy away from .reduce and start using it in the projects!
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.
I have myself found
.reduce
to be very useful however, I think one must atleast put some time in naming theaccumulator
comprehensively so, it is self-evident what the list of items will be reduced to. Personally, in the first example, I would have namedaccumulator
to besum
ortotal
. In the second example,shortestWord
. In the third (tricky) example, perhaps,reverseObject
and, I would have definedreverseObject
to be an object that has their keys / values swapped (as a comment).However, like Ben said, this would definitely help JS developers to not shy away from
.reduce
and start using it in the projects!