Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 600 Bytes

dataSum.md

File metadata and controls

27 lines (18 loc) · 600 Bytes

Back to reference

dataSum(data, prop)

Calculates the sum of values of a given property prop from all entries in data.

Example:

If you have data like this:

let superheroes = [
  {Name: "Superboy", Height: 170, Weight: 68},
  {Name: "Supergirl", Height: 165, Weight: 54},
  {Name: "Superman", Height: 191, Weight: 101}
]

This will sum up the Height values of all entries in superheroes:

let heightSum = gmynd.dataSum(superheroes, "Height");

// 170 + 165 + 191 = 526

Credits: bottens