Skip to content

Instantly share code, notes, and snippets.

@anabastos
Created March 9, 2017 18:54
Show Gist options
  • Save anabastos/fbdfef7fcc64105e76e5e26218ebf7e6 to your computer and use it in GitHub Desktop.
Save anabastos/fbdfef7fcc64105e76e5e26218ebf7e6 to your computer and use it in GitHub Desktop.
Desafio 1
//dado o array de dictionary abaixo some o total dos valores
let dictionary = [{ '5': 50, '6': 60 }, { 'A': 10 }, { 'YEEZY': 30 }]
dictionary.reduce((acc, val) => acc.concat(Object.values(val)), []).reduce((acc, val) => acc + val, 0)
@beatorizu
Copy link

function sum_items(list_items) {
  var sum = 0;
  list_items.map(
    function (item) {
      for (var key in item) {
        sum += item[key];
      }
    }
  );
  return sum;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment