Skip to content

bsiddiqui/summm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

summm

Build Status Code Climate Version Downloads

Summm safely adds numbers in Javascript by ensuring the values are valid numbers and typecasting them prior to evaluation. This ensures that you actually add numbers instead of concating them.

Install

$ npm install --save summm

Usage

var sum = require('summm')

sum(4, 2)
// => 6

sum('4', 2)
// => 6

sum([4, 2, 1])
// => 7

API

sum(numbers) -> number

numbers

Required
Type: number \ array of numbers

The numbers you'd like to get the sum of. Can be an array of numbers or each number provided as an argument.