reduce-sum

1.0.1 • Public • Published

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

Dependencies (0)

    Dev Dependencies (11)

    Package Sidebar

    Install

    npm i reduce-sum

    Weekly Downloads

    2

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    164 kB

    Total Files

    9

    Last publish

    Collaborators

    • jxsh