Elffuss BraidHub

kikocis/continue public

e31fcddb0dec · 487 BRawPermalink
1class Calculator {
2 constructor() {
3 this.result = 0;
4 }
5
6 add(number) {
7 this.result += number;
8 return this;
9 }
10 subtract(number) {
11 return this;
12 }
13
14 multiply(number) {
15 this.result *= number;
16 return this;
17 }
18
19 divide(number) {
20 if (number === 0) {
21 throw new Error("Cannot divide by zero");
22 }
23 this.result /= number;
24 return this;
25 }
26
27 getResult() {
28 return this.result;
29 }
30
31 reset() {
32 this.result = 0;
33 return this;
34 }
35}