Skip to content

Commit 6c99cba

Browse files
committed
worked on making my calculate methond more efficient
1 parent b4e3360 commit 6c99cba

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lesson_06/expression/src/expression_calculator.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ export class ExpressionCalculator {
22
/** Returns the calculation of ((a + b) * c) / d^e */
33
calculate(a: number, b: number, c: number, d: number, e: number): number {
44
// Implement your code here to return the correct value.
5-
return this.divide(this.multiply(this.add(a, b), c), this.pow(d, e));
5+
const sum = this.add(a, b);
6+
const product = this.multiply(sum, c);
7+
const exp = this.pow(d, e);
8+
const quotient = this.divide(product, exp);
9+
return quotient;
610
}
711

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

0 commit comments

Comments
 (0)