Skip to content
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

feat: adds Shawn lesson06 #278

Closed
Closed
Changes from all 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
15 changes: 14 additions & 1 deletion lesson_06/expression/src/expression_calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down