sum-list
v1.0.0
Published
Add up all of the numbers in an array of numbers. Also works when non-numbers are present as well.
Downloads
24
Readme
sum-list
Add up all of the numbers in an array of numbers. Also works when non-numbers are present as well.
Features
npm
Install
npm install --save sum-list
Script Tag
For Development
<script src="https://rawgit.com/Prosen-Ghosh/sum-list/master/sum.js"></script>
For Production
<script src="https://cdn.rawgit.com/Prosen-Ghosh/sum-list/ed0e191c/sum.js"></script>
Usage
var sum = require('sum-list')
sum([1,2,3,4]);
//=> 10
sum([1,2,3,4,10]);
//=> 20
sum([1,2,3,"as",{},[],9]);
//=> 15
sum([1,2,3,"as",{},[]]);
//=> 6
//TypeError
sum(); // Without parameter function call will throw an type error
//=> TypeError: sum() expects an array parameter
Author
Prosen Ghosh [email protected]
License
- MIT