npm install basic-maths
// with require
const { basicMaths } = require("basic-maths");
// with import
import { basicMaths } from 'basic-maths';
// methods
const add = basicMaths.add(1, 3); // return 4
const substract = basicMaths.substract(1, 2); // return -1
const multiply = basicMaths.multiply(1, 2); // return 2
const divideGood = basicMaths.divide(1, 2); // Good - return 0.5
const divideBad = basicMaths.divide(1, 0); // Bad - No number is divisible by zero
const powOperation = basicMaths.powOperation(2, 2); // return 8
If your application is not from Node and you still want to use it on the frontend, you can import the CDN that is hosted on jsDelivr
Just copy and paste in your html this script
<script src="https://cdn.jsdelivr.net/npm/[email protected]/build-browser/index.min.js"></script>