Skip to content

returns the sum of the values of the same named property off all objects in the list supplied

License

Notifications You must be signed in to change notification settings

WebForgeOSS/sum-of

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sum-of

Returns the sum of the values of the same property off all objects in the supplied list

Build Status Coverage Status Maintainability Language grade: JavaScript tested with jest code style: prettier

Install

$ npm install sum-of

Usage

const sumOf = require("sum-of");

const objects = [{ a: 2 }, { a: 3, b: 1 }];

sumOf(["a"], objects); //=> 5

API

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 }]); //=> 5

License

MIT © muceres

About

returns the sum of the values of the same named property off all objects in the list supplied

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •