Skip to content

Simple calculation of average values for an array of objects

Notifications You must be signed in to change notification settings

SanichKotikov/average-array-objects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Simple calculation of average values for an array of objects.
Note: used Array.prototype.includes() and Number.isFinite().

Install

$ npm i average-array-objects --save

Usage

import getAverages from 'average-array-objects';

const rows = [
    { id: 1, a: 456, b: 635, c: 682 },
    { id: 2, a: 100, b: 99, c: 33 },
    { id: 3, a: 283, b: 238, c: 123 },
];

const skip = ['id'];

const result = getAverages(rows, skip);
// ==> {"a":279.6666666666667,"b":324,"c":279.3333333333333}

License

MIT

About

Simple calculation of average values for an array of objects

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published