diff --git a/lesson_06/expression/src/expression_calculator.ts b/lesson_06/expression/src/expression_calculator.ts index 13cb2ca0..8f95e10c 100644 --- a/lesson_06/expression/src/expression_calculator.ts +++ b/lesson_06/expression/src/expression_calculator.ts @@ -2,9 +2,22 @@ export class ExpressionCalculator { /** Returns the calculation of ((a + b) * c) / d^e */ calculate(a: number, b: number, c: number, d: number, e: number): number { // Implement your code here to return the correct value. - return 0; + const add = this.add(a, b); + const multiply = this.multiply(add, c); + const divide = this.divide(multiply, this.pow(d, e)); + + return divide; } + add(num1: number, num2: number): number { + return num1 + num2; + } + multiply(num1: number, num2: number): number { + return num1 * num2; + } + divide(num1: number, num2: number): number { + return num1 / num2; + } pow(base: number, exponent: number): number { return Math.pow(base, exponent); }