An open API service indexing awesome lists of open source software.

https://github.com/nhsz/sumar

Sum all the values of an array, if they are all numeric
https://github.com/nhsz/sumar

Last synced: 5 months ago
JSON representation

Sum all the values of an array, if they are all numeric

Awesome Lists containing this project

README

          

# sumar

[![NPM](https://nodei.co/npm/sumar.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/sumar/)

> Sum all the values of an array, if they are all numeric

## Install

```
$ npm install --save sumar
```

## Usage

```js
const sum = require('sumar')

console.log(sum([]))
// => 0

console.log(sum([1]))
// => 1

console.log(sum([0, 1, 2, 3]))
// => 6

console.log(sum([27, 421, -8, 0, -154, 23, 11, 256]))
// => 576
```

## License

MIT © **[`Nicolás Quiroz`](https://nicolasquiroz.com)**