UNPKG
sagar-node-app
Version:
latest (1.5.0)
1.5.0
Sample nodeJS application created as part of NodeJS training 1st program
sagar-node-app
/
calculator.js
21 lines
(17 loc)
•
290 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function
add
(
a,b
){
return
a+b; }
function
sub
(
a,b
){
return
a-b; }
function
mul
(
a,b
){
return
a*b; }
function
divide
(
a,b
){
if
(b===
0
)
throw
new
Error
(
"You cannot divide using zero"
);
return
a/b; }
module
.
exports
={ add, mul, sub, divide }