Skip to content

Instantly share code, notes, and snippets.

@sandrabosk
Created July 10, 2020 16:32
Show Gist options
  • Select an option

  • Save sandrabosk/9671989ca066e48a22612071f420878f to your computer and use it in GitHub Desktop.

Select an option

Save sandrabosk/9671989ca066e48a22612071f420878f to your computer and use it in GitHub Desktop.
  1. Calculate the total population in the given array (data):
const data = [
  {
    country: 'USA',
    pop: 340,
  },
  {
    country: 'France',
    pop: 133,
  },
  {
    country: 'Bosnia',
    pop: 5,
  }
]

// ... your code here

// expected output: 478
  1. Given a menu of foods and their calories, calculate the average number of calories for the entire list.
const menu = [
  { name: 'Carrots', calories: 150 },
  { name: 'Steak', calories: 350 },
  { name: 'Broccoli', calories: 120 },
  { name: 'Chicken', calories: 250 },
  { name: 'Pizza', calories: 520 }
];

// ... your code here

// expected output: 278
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment