The Javascript Array.reduce() method you didn’t know existed

For to often I see developers do something like this

The code block loops through an array of numbers and adds them to a number outside the loop. The end result will produce a variable that contains the sum of all numbers in the array.

However, the solution can be expressed in terms that correspond to the problem being solved. Even though the results are going to be same, future developers who may inherit that code will thank you for having a clear and concise code block.

AWS Devops Guy (

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store