sum-of
v1.0.1
Published
Returns the sum of the values of the same property off all objects in the supplied list
Readme
sum-of
Returns the sum of the values of the same property off all objects in the supplied list
Install
$ npm install sum-ofUsage
const sumOf = require("sum-of");
const objects = [{ a: 2 }, { a: 3, b: 1 }];
sumOf(["a"], objects); //=> 5API
sumOf ⇒ Number
Returns the sum of the values of the same property off all objects in the supplied list
Returns: Number - sum of the selected properties
Sig: [a] -> [a] -> Number
| Param | Type | Description |
| ------- | ---------- | ------------------------------- |
| path | String[] | the path to work with |
| objects | Object[] | objects to retrieve values from |
Example
sumOf(["a"], [{ a: 2 }, { a: 3, b: 1 }]); //=> 5License
MIT © saxjst
