1.2.0 • Published 2 years ago
return-sum v1.2.0
Install
Install with npm:
$ npm install --save return-sum
Usage
sum()
The sum() function can add multiple parameters and return the sum. **Just work with numbers.
const {sum} = require('return-sum');
console.log(sum()) //=>0
console.log(sum(1,2)) //=>3
console.log(sum(1,2,3)) //=>6
**If the parameters is not type of number, it would counts 0 for that parameters.
console.log(sum("1",2)) //=>2
sumArr()
if you want to send an number array ,you should use this one,the sumArr() function takes in an array and return the sum. **each item of array should be number,or it would counts 0 for that item.
const {sumArr} = require('return-sum');
console.log(sumArr([-1,1,3])) //3
console.log(sumArr(["a","1",2])) //2
Author
Meng Tse Houng
License
Copyright © 2022, Meng Tse Houng. Released under the MIT License.