Skip to content

feat:Tommy Tran Lesson_06 solution #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion lesson_06/expression/src/expression_calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,31 @@ 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 ab = this.add(a, b);
const abc = this.multiply(ab, c);
const de = this.pow(d, e);
const answer = this.divide(abc, de);
return answer;
}

add(a: number, b: number): number {
return a + b;
}

multiply(add: number, c: number): number {
return add * c;
}

divide(multiply: number, d: number): number {
return multiply / d;
}

pow(base: number, exponent: number): number {
return Math.pow(base, exponent);
}
}
/* onst add = a + b;
const multiply = add * c;
const divide = multiply / this.pow(d, e);*/
/** (a + b) * c) / this.pow(d, e) */