1.0.3 • Published 1 year ago
test_cal_ss v1.0.3
Calculator Module
This is a simple calculator module that provides basic arithmetic operations such as addition, subtraction, multiplication, and division.
Installation
To use this module, you need to have Node.js installed. You can include this module in your project by copying the code into a file named calculator.js.
Usage
- Create a file named
calculator.jsand paste the provided code for the calculator module. - In your main project file, require the
calculatormodule and use its methods for arithmetic operations.
API
The calculator module provides the following methods:
add(a, b): Returns the sum ofaandb.substract(a, b): Returns the difference ofaandb.multiplay(a, b): Returns the product ofaandb.divide(a, b): Returns the quotient ofaandb.
Example
Here's an example of how to use the calculator module in your project:
- Create a
calculator.jsfile with the module code. - In your main file, require and use the calculator module to perform arithmetic operations.
const calculator = require('./calculator');
const num1 = 10;
const num2 = 5;
console.log(`Addition: ${calculator.add(num1, num2)}`); // Output: 15
console.log(`Subtraction: ${calculator.substract(num1, num2)}`); // Output: 5
console.log(`Multiplication: ${calculator.multiplay(num1, num2)}`); // Output: 50
console.log(`Division: ${calculator.divide(num1, num2)}`); // Output: 2