Skip to content

jxshco/reduce-sum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

reduce-sum

travis npm version npm downloads Standard - JavaScript Style Guide

Returns a total sum of specific key of an array of objects

Table of Contents

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!

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published