reduce-sum
v1.0.1
Published
Returns a total sum of specific key of an array of objects
Downloads
5
Readme
Table of Contents
- Quick start
Install
Add reduce-sum to your project using npm or yarn.
Install (NPM):
$ npm install reduce-sum --save
Install (Yarn):
$ yarn add reduce-sum
Usage
Import ReduceSum into Your Project
import ReduceSum from 'reduce-sum'
Use ReduceSum
ReduceSum([{ a: 139, c: 22 }, { a: 233, b: 'hi' }, { a: 112, b: 18 }], 'a')
// 484
let cart = [{ name: 'Jeans', quantity: 1 }, { name: 'Socks', quantity: 3 }, { name: 'T-Shirt', quantity: 6 }]
let totalItems = reduceSum(cart, 'quantity')
// 10
Contributing
Pull requests for new features, bug fixes, and suggestions are welcome!