8000 Revision of Calculator · anshi-the-coder/Javascript@7545c38 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7545c38

Browse files
Revision of Calculator
1 parent f642af7 commit 7545c38

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

MyCalculator.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const add 8000 = (a, b) => {
2+
return a + b;
3+
};
4+
const sub = (a, b) => {
5+
return a - b;
6+
};
7+
const mul = (a, b) => {
8+
return a * b;
9+
};
10+
const div = (a, b) => {
11+
return a / b;
12+
};
13+
14+
const calculator = (c, d, task) => {
15+
switch (task) {
16+
case "add":
17+
return add(c, d);
18+
case "sub":
19+
return sub(c, d);
20+
case "mul":
21+
return mul(c, d);
22+
case "div":
23+
return div(c, d);
24+
default:
25+
return `The task ${task} is not defined`
26+
}
27+
};
28+
29+
let c =5
30+
let d=10
31+
let value=calculator(c,d,"add")
32+
console.log(value)
33+
value = calculator(c,d,"sub")
34+
console.log(value)
35+
value = calculator(c,d,"mul")
36+
console.log(value)
37+
value=calculator(c,d,"div")
38+
console.log(value)

0 commit comments

Comments
 (0)
0