.reduce() = reduce the elements of an array to a single value
const prices = [5, 30, 10, 25, 15, 20];
const total = prices.reduce(sum);
console.log(`$${total.toFixed(2)}`);
function sum(previous, next){
return previous + next;
}const grades = [56, 38, 90, 25, 15, 70];
const maximum = grades.reduce(getMax);
console.log(maximum);
function getMax(accumulator, element){
return Math.max(accumulator, element);
}