Skip to content

Commit 289f57e

Browse files
author
AmiyahJo
committed
it works!!!
1 parent 10ce713 commit 289f57e

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

lesson_06/expression/src/expression_calculator.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,34 @@ export class ExpressionCalculator {
33
calculate(a: number, b: number, c: number, d: number, e: number): number {
44
// Implement your code here to return the correct value.
55

6-
//PEMDAS order -> expected : //((a + b) * c) / d^e
76
// 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;
1417

15-
return FinalResult;
1618
}
1719

18-
add(x: number , y: number){
20+
add(x: number, y: number) {
1921
return x + y;
2022
}
2123

22-
multiply(x: number , y: number){
24+
multiply(x: number, y: number) {
2325
return x * y;
2426
}
2527

26-
divide(x: number, y: number){
28+
divide(x: number, y: number) {
2729
return x / y;
2830
}
2931

3032
pow(base: number, exponent: number): number {
3133
return Math.pow(base, exponent);
32-
}
34+
}
3335
}
3436

35-
//npm run compile = update code
36-
//npm start = check your code
37-
//npm run check = check it;

0 commit comments

Comments
 (0)