The first parameter accumulates the values, and the last parameter is the current value in the array. In this scenario, the array have 7 numbers which means it will execute 6 times (starts on index 1) and moves from left to right while only adding two numbers per execution (callback). Similar concept to bubble-sort, except it sums up values rather sorting. For more details, click here.

Software Engineer sharing interesting tech topics

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