somacoder
v1.0.3
Published
`soma` is a simple JavaScript function that sums any number of numeric arguments. It handles various edge cases, such as no input, non-numeric values, and negative numbers.
Readme
soma
soma is a simple JavaScript function that sums any number of numeric arguments. It handles various edge cases, such as no input, non-numeric values, and negative numbers.
Installation
Install the package via npm:
npm install somaCoderUsage
After installation, you can use the soma function in your project:
const { soma } = require('somaCoder');
console.log(soma(1, 2, 3)); // Output: 6Example
// Summing multiple numbers
soma(1, 2, 3); // returns 6
// No arguments
soma(); // returns 0
// Non-numeric argument
soma(1, "2", 3); // returns null
// Handling negative numbers
soma(-1, -2, -3); // returns -6Running Tests
This package comes with a test suite powered by Jest. To run the tests, follow these steps:
Clone the repository from GitHub:
git clone [email protected]:marianamohr/somaCoder.gitNavigate into the project directory:
cd somaCoderInstall the dependencies:
npm installRun the tests:
npm run test
The tests include scenarios for:
- Correct summing of numeric arguments.
- Handling of non-numeric arguments.
- Proper behavior when no arguments are passed.
- Summing of negative numbers.
