You can create array simply as – var arrayName =  . expenditure value. The Basic For Loop . Algorithm You can use the reduce() method to find or calculate the sum of an array of numbers.
As well as demo example.
Demonstration of using Array.prototype.reduce() method for calculating sum of array elements