// function that takes in the current state, and an action to update it
// you just pass whatever the action you want to perform on the current state
// and it will go ahead and update it
const arr = [2, 10, 40];
const initValue = 0;
const sumWithInitValue = arr.reduce((prevValue, currentValue) => {
return prevValue + currentValue
}, initValue);
console.log(`sum is ${sumWithInitValue}`) // > "sum is 52"