Skip to content

Chutt_lesson_06: added Expression Calculator #259

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 4 commits into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lesson_06/expression/.env.test
Original file line number Diff line number Diff line change
@@ -1 +1 @@
HW_VERSION=your assigned version here
HW_VERSION=C
18 changes: 17 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,26 @@ export class ExpressionCalculator {
/** Returns a calculation involving a, b, c, d, and e */
calculate(a: number, b: number, c: number, d: number, e: number): number {
// Implement your code here to return the correct value.
return 0;
// a / b + c * Math.pow(d, e),
const division = this.divide(a, b);
const exponentation = this.pow(d, e);
const multiply = this.multiply(c, exponentation);
const result = this.add(division, multiply);
return result;
}

divide(a: number, b: number): number {
return a / b;
}

pow(base: number, exponent: number): number {
return Math.pow(base, exponent);
}
multiply(c: number, f: number): number {
return c * f;
}

add(num1: number, num2: number): number {
return num1 + num2;
}
}
166 changes: 31 additions & 135 deletions lesson_06/quiz/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions lesson_06/quiz/src/lesson5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class Lesson5 {
[AnswerChoice.C, "To insert an image"],
[AnswerChoice.D, "To create a paragraph"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice. B,
);
}

Expand All @@ -52,7 +52,7 @@ export class Lesson5 {
[AnswerChoice.C, "alt"],
[AnswerChoice.D, "href"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice. C,
);
}

Expand All @@ -66,7 +66,7 @@ export class Lesson5 {
[AnswerChoice.C, "<div>"],
[AnswerChoice.D, "<link>"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice. D,
);
}

Expand All @@ -80,7 +80,7 @@ export class Lesson5 {
[AnswerChoice.C, "<span>"],
[AnswerChoice.D, "<br>"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice. C,
);
}

Expand All @@ -94,7 +94,7 @@ export class Lesson5 {
[AnswerChoice.C, "Computer Style Sheets"],
[AnswerChoice.D, "Cascading System Sheets"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice. B,
);
}

Expand All @@ -108,7 +108,7 @@ export class Lesson5 {
[AnswerChoice.C, "text-color"],
[AnswerChoice.D, "background-color"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice. A,
);
}

Expand All @@ -122,7 +122,7 @@ export class Lesson5 {
[AnswerChoice.C, "/* this is a comment */"],
[AnswerChoice.D, "<!-- this is a comment -->"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice. C,
);
}

Expand All @@ -136,7 +136,7 @@ export class Lesson5 {
[AnswerChoice.C, "text-size"],
[AnswerChoice.D, "text-style"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice. B,
);
}

Expand All @@ -150,7 +150,7 @@ export class Lesson5 {
[AnswerChoice.C, "inline-block"],
[AnswerChoice.D, "none"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice. A,
);
}

Expand All @@ -164,7 +164,7 @@ export class Lesson5 {
[AnswerChoice.C, "<stylesheet link='styles.css'>"],
[AnswerChoice.D, "<css href='styles.css'>"],
]),
AnswerChoice.UNANSWERED,
AnswerChoice. C,
);
}
}
Expand Down
Loading