ES 2015

Array methods - reduce

reduce - example 1

Adding up all the ages in the ages array.
const ages = [14, 16, 38, 7, 74, 28, 17, 44, 56];

Using a regular function notation:
const agesTotal = ages.reduce(function(total,age){
  return total + age;
},0);

Or on one line, using the arrow function notation:
const agesTotal = ages.reduce((total,age) => total + age, 0);
RESULT ADDING UP AGES