This is a simple calculator package.
First install the package.
npm i calculator.js
Then, import it.
const Calculator = require("calculator.js");
const calc = new Calculator();
Add numbers.
const num = calc.add(1,2);
console.log(num);
console.log(num === 3);
Subtract numbers.
const num = calc.subtract(1,2);
console.log(num);
console.log(num === 1);
Multiply numbers.
const multiply = calc.multiply(1,2);
console.log(num);
console.log(num === 2);
Divide numbers.
const num = calc.divide(5,10);
console.log(num);
console.log(num === 2);
Round numbers:
Add numbers.
const num = calc.add(0.5,10,true);
console.log(num);
console.log(num === 10);
Subtract numbers.
const num = calc.subtract(1,2.5,true);
console.log(num);
console.log(num === 1);
Multiply numbers.
const multiply = calc.multiply(1,10.5,true);
console.log(num);
console.log(num === 10);
Divide numbers.
const num = calc.divide(1,10.5,true);
console.log(num);
console.log(num === 10);