Skip to content

Commit 1ec7405

Browse files
committed
feat refine calculation logic in ExpressionCalculatoor
1 parent 3a96919 commit 1ec7405

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

lesson_06/expression/src/expression_calculator.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
export class ExpressionCalculator {
22
/** Returns a calculation involving a, b, c, d, and e */
33
calculate(a: number, b: number, c: number, d: number, e: number): number {
4-
// Implement your code here to return the correct value.
5-
const base: number = this.add(b, c);
6-
const expo: number = d;
7-
8-
return this.divide(this.multiply(a, this.pow(base, expo)), e);
4+
// Function to implement: a * Math.pow(b + c, d) / e
5+
const addition = this.add(b, c);
6+
const exponentiation = this.pow(addition, d);
7+
const multiplication = this.multiply(a, exponentiation);
8+
const division = this.divide(multiplication, e);
9+
return division;
910
}
1011

1112
pow(base: number, exponent: number): number {

0 commit comments

Comments
 (0)