Reduce A JSON Object Of Key Value Pairs To A Single Total In JavaScript

The title says it all on this one, if you have an object like:

const ingredients = {
  'apples': 3,
  'oranges': 9,
  'pears': 4
}

and you want to calculate the total number of items you have then you can do:

const sum = Object.keys(ingredients)
  .map(ingredientKey => {
    // get an array of numbers
    return ingredients[ingredientKey];
  })
  .reduce((sum, el) => {
    // sum that array of numbers
    return sum + el;
  }, 0);