@@ -3,35 +3,34 @@ export class ExpressionCalculator {
3
3
calculate ( a : number , b : number , c : number , d : number , e : number ) : number {
4
4
// Implement your code here to return the correct value.
5
5
6
- //PEMDAS order -> expected : //((a + b) * c) / d^e
7
6
// Caculate addition with an add function '(a + b)'
8
- const originalSum = this . add ( a , b ) ;
9
- // caculate multiplication '(add * c)' and 'd^e' so d * (e times)
10
- const MultiplyMySum = this . multiply ( originalSum , c )
11
- // caculate division with divide function which is different variables of the multiplication values '(add * c)' and 'd^e' so d * (e times)
12
- const FinalResult = this . divide ( MultiplyMySum , d ^ e ) ;
13
- // needs caculate something...
7
+ const originalSum = this . add ( a , b ) ;
8
+ // caculate multiplication '(add * c)'
9
+ const MultiplyMySum = this . multiply ( originalSum , c ) ;
10
+ //Specify the exponent 'd^e'
11
+ const myExponent = this . pow ( d , e ) ;
12
+ // caculate division 'multiply / exponent'
13
+ const DivideSum = this . divide ( MultiplyMySum , myExponent ) ;
14
+ // needs caculate it all...
15
+ const calculate = DivideSum ;
16
+ return calculate ;
14
17
15
- return FinalResult ;
16
18
}
17
19
18
- add ( x : number , y : number ) {
20
+ add ( x : number , y : number ) {
19
21
return x + y ;
20
22
}
21
23
22
- multiply ( x : number , y : number ) {
24
+ multiply ( x : number , y : number ) {
23
25
return x * y ;
24
26
}
25
27
26
- divide ( x : number , y : number ) {
28
+ divide ( x : number , y : number ) {
27
29
return x / y ;
28
30
}
29
31
30
32
pow ( base : number , exponent : number ) : number {
31
33
return Math . pow ( base , exponent ) ;
32
- }
34
+ }
33
35
}
34
36
35
- //npm run compile = update code
36
- //npm start = check your code
37
- //npm run check = check it;
0 commit comments