Skip to content

Instantly share code, notes, and snippets.

@Woodsphreaker
Created March 18, 2017 18:17
Show Gist options
  • Save Woodsphreaker/5eb6b99cd9182c23bf32637b095308ea to your computer and use it in GitHub Desktop.
Save Woodsphreaker/5eb6b99cd9182c23bf32637b095308ea to your computer and use it in GitHub Desktop.
Some os valores dos objetos
const obj = [{ '5': 50, '6': 60 }, { 'A': 10 }, { 'YEEZY': 30 }];
const arrNumbers = () => obj.map(_a => Object.values(_a));
const onlyNumbers = () => [].concat(...arrNumbers());
const result = () => onlyNumbers().reduce((_a, _b) => _a + _b, 0);
console.log(result()); // 150
Some os valores dos objetos
Dado o array de dictionary abaixo some o total dos valores
[{ '5': 50, '6': 60 }, { 'A': 10 }, { 'YEEZY': 30 }]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment