From 1948810dddcc7d0d097588ffa1703b0817abdfe3 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 17 Mar 2025 17:25:05 +0000 Subject: [PATCH 01/11] Chore: Submited answers for Quiz --- lesson_06/quiz/src/lesson5.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lesson_06/quiz/src/lesson5.ts b/lesson_06/quiz/src/lesson5.ts index 9ad62bd67..ddcfa4f50 100644 --- a/lesson_06/quiz/src/lesson5.ts +++ b/lesson_06/quiz/src/lesson5.ts @@ -38,7 +38,7 @@ export class Lesson5 { [AnswerChoice.C, "To insert an image"], [AnswerChoice.D, "To create a paragraph"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -52,7 +52,7 @@ export class Lesson5 { [AnswerChoice.C, "alt"], [AnswerChoice.D, "href"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.C, ); } @@ -66,7 +66,7 @@ export class Lesson5 { [AnswerChoice.C, "
"], [AnswerChoice.D, ""], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -80,7 +80,7 @@ export class Lesson5 { [AnswerChoice.C, ""], [AnswerChoice.D, "
"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.D, ); } @@ -94,7 +94,7 @@ export class Lesson5 { [AnswerChoice.C, "Computer Style Sheets"], [AnswerChoice.D, "Cascading System Sheets"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -108,7 +108,7 @@ export class Lesson5 { [AnswerChoice.C, "text-color"], [AnswerChoice.D, "background-color"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -122,7 +122,7 @@ export class Lesson5 { [AnswerChoice.C, "/* this is a comment */"], [AnswerChoice.D, ""], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.C, ); } @@ -136,7 +136,7 @@ export class Lesson5 { [AnswerChoice.C, "text-size"], [AnswerChoice.D, "text-style"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -150,7 +150,7 @@ export class Lesson5 { [AnswerChoice.C, "inline-block"], [AnswerChoice.D, "none"], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.B, ); } @@ -164,7 +164,7 @@ export class Lesson5 { [AnswerChoice.C, ""], [AnswerChoice.D, ""], ]), - AnswerChoice.UNANSWERED, + AnswerChoice.A, ); } } From d03f672a83e645d03783b81cd45b012b1ea3c5f6 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 17 Mar 2025 20:12:28 +0000 Subject: [PATCH 02/11] Feat/ Adds return function --- lesson_06/expression/.env.test | 2 +- lesson_06/expression/src/expression_calculator.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lesson_06/expression/.env.test b/lesson_06/expression/.env.test index 56cf4a06f..93aef4eca 100644 --- a/lesson_06/expression/.env.test +++ b/lesson_06/expression/.env.test @@ -1 +1 @@ -HW_VERSION=your assigned version here \ No newline at end of file +HW_VERSION=F \ No newline at end of file diff --git a/lesson_06/expression/src/expression_calculator.ts b/lesson_06/expression/src/expression_calculator.ts index 76b215c42..f220ff71e 100644 --- a/lesson_06/expression/src/expression_calculator.ts +++ b/lesson_06/expression/src/expression_calculator.ts @@ -2,7 +2,7 @@ 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; + return (a * this.pow(b + c, d)) / e; } pow(base: number, exponent: number): number { From f4b34d43538094c3c8df15dc3bd150f2a134d5dd Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 17 Mar 2025 20:31:35 +0000 Subject: [PATCH 03/11] Chore: updates json file --- package-lock.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 000000000..7ffd06b2c --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "code-differently-25-q1-fork", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} From 0e2d3a378f8da7bef4dff61cec8dd8b7f7085844 Mon Sep 17 00:00:00 2001 From: "Anthony D. Mays" Date: Mon, 17 Mar 2025 13:32:54 -0400 Subject: [PATCH 04/11] chore: adds git checks for lesson 06 quiz (#254) Signed-off-by: Anthony D. Mays --- .github/workflows/check_lesson_06_quiz.yaml | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/check_lesson_06_quiz.yaml diff --git a/.github/workflows/check_lesson_06_quiz.yaml b/.github/workflows/check_lesson_06_quiz.yaml new file mode 100644 index 000000000..deaea1baa --- /dev/null +++ b/.github/workflows/check_lesson_06_quiz.yaml @@ -0,0 +1,32 @@ +name: Check Lesson 06 Quiz Pull Request + +on: + pull_request: + branches: [ "main" ] + paths: + - "lesson_06/quiz/**" + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + + - name: Build Shared Lib with Node.js + working-directory: ./lib/javascript/codedifferently-instructional + run: npm ci + + - name: Build Lesson 06 Quiz with Node.js + working-directory: ./lesson_06/quiz + run: | + npm ci + npm run check \ No newline at end of file From 9fe1877aa15bb041d33e07dcb63750c00bbc984c Mon Sep 17 00:00:00 2001 From: "Anthony D. Mays" Date: Mon, 17 Mar 2025 12:11:44 -0700 Subject: [PATCH 05/11] fix: updates doco to include missing command (#268) Signed-off-by: Anthony D. Mays --- lesson_06/README.md | 1 + lesson_06/expression/src/lesson6.test.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lesson_06/README.md b/lesson_06/README.md index cab259851..bdd1cffdb 100644 --- a/lesson_06/README.md +++ b/lesson_06/README.md @@ -23,6 +23,7 @@ HW_VERSION=D ``` 2. Run the program to determine the expression you must implement. ```bash +npm install npm run compile npm start ``` diff --git a/lesson_06/expression/src/lesson6.test.ts b/lesson_06/expression/src/lesson6.test.ts index c324ca280..b222ccd55 100644 --- a/lesson_06/expression/src/lesson6.test.ts +++ b/lesson_06/expression/src/lesson6.test.ts @@ -39,7 +39,7 @@ describe("Lesson6Test", () => { test("testAdd_works", () => { // Act - const result = calculator.add(1, 2); + const result = calculator.add(2, 3); // Assert expect(result).toBe(3); From b3c712199ce48f02740bbcf9beecc7ef7750178b Mon Sep 17 00:00:00 2001 From: "Anthony D. Mays" Date: Mon, 17 Mar 2025 12:19:25 -0700 Subject: [PATCH 06/11] chore: adds lesson 6 actions and checks (#269) * chore: adds lesson 6 actions and checks Signed-off-by: Anthony D. Mays * chore: updates push actions Signed-off-by: Anthony D. Mays --------- Signed-off-by: Anthony D. Mays --- .github/workflows/check_lesson_06_pr.yaml | 32 +++++++++++++++++++++++ .github/workflows/check_push.yml | 16 ++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 .github/workflows/check_lesson_06_pr.yaml diff --git a/.github/workflows/check_lesson_06_pr.yaml b/.github/workflows/check_lesson_06_pr.yaml new file mode 100644 index 000000000..8c667d78e --- /dev/null +++ b/.github/workflows/check_lesson_06_pr.yaml @@ -0,0 +1,32 @@ +name: Check Lesson 06 Pull Request + +on: + pull_request: + branches: [ "main" ] + paths: + - "lesson_06/expression/**" + +jobs: + build: + + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' + + - name: Build Shared Lib with Node.js + working-directory: ./lib/javascript/codedifferently-instructional + run: npm ci + + - name: Build Lesson 06 with Node.js + working-directory: ./lesson_06/expression + run: | + npm ci + npm run check \ No newline at end of file diff --git a/.github/workflows/check_push.yml b/.github/workflows/check_push.yml index 8fb59f86a..62cbaf896 100644 --- a/.github/workflows/check_push.yml +++ b/.github/workflows/check_push.yml @@ -8,6 +8,8 @@ on: - "lib/**" - "lesson_02/quiz/**" - "lesson_03/quiz/**" + - "lesson_06/quiz/**" + - "lesson_06/expression/**" jobs: build: runs-on: ubuntu-latest @@ -71,3 +73,17 @@ jobs: npm ci npm run compile npm run lint + + - name: Build Lesson 06 Quiz with Node.js + working-directory: ./lesson_06/quiz + run: | + npm ci + npm run compile + npm run lint + + - name: Build Lesson 06 Expression with Node.js + working-directory: ./lesson_06/expression + run: | + npm ci + npm run compile + npm run lint From 043abc068d1d7b13aea350d34b8bac262b3e721a Mon Sep 17 00:00:00 2001 From: "Anthony D. Mays" Date: Mon, 17 Mar 2025 12:24:35 -0700 Subject: [PATCH 07/11] fix: updates push action (#270) Signed-off-by: Anthony D. Mays --- .github/workflows/check_push.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/check_push.yml b/.github/workflows/check_push.yml index 62cbaf896..5edb6e191 100644 --- a/.github/workflows/check_push.yml +++ b/.github/workflows/check_push.yml @@ -86,4 +86,3 @@ jobs: run: | npm ci npm run compile - npm run lint From 49b0ab18d352a1d9ad62bcd362b6c069e33bc1db Mon Sep 17 00:00:00 2001 From: "Anthony D. Mays" Date: Mon, 17 Mar 2025 12:44:30 -0700 Subject: [PATCH 08/11] chore: fix lint errors (#271) Signed-off-by: Anthony D. Mays --- lesson_06/expression/src/functions.ts | 33 ++++++++++++------------ lesson_06/expression/src/lesson6.test.ts | 2 +- lesson_06/expression/src/lesson6.ts | 2 +- lesson_06/expression/src/utils.ts | 8 +++--- 4 files changed, 23 insertions(+), 22 deletions(-) diff --git a/lesson_06/expression/src/functions.ts b/lesson_06/expression/src/functions.ts index ab7433c9c..e193d2f9b 100644 --- a/lesson_06/expression/src/functions.ts +++ b/lesson_06/expression/src/functions.ts @@ -1,16 +1,17 @@ -export const FUNCTIONS: Record = Object.freeze({ - A: (a: number, b: number, c: number, d: number, e: number) => - ((a + b) * c) / Math.pow(d, e), - B: (a: number, b: number, c: number, d: number, e: number) => - Math.pow(a + b, c) / (d * e), - C: (a: number, b: number, c: number, d: number, e: number) => - a / b + c * Math.pow(d, e), - D: (a: number, b: number, c: number, d: number, e: number) => - (a * b) / Math.pow(c + d, e), - E: (a: number, b: number, c: number, d: number, e: number) => - Math.pow((a + b) / c, d) * e, - F: (a: number, b: number, c: number, d: number, e: number) => - (a * Math.pow(b + c, d)) / e, - G: (a: number, b: number, c: number, d: number, e: number) => - ((Math.pow(a, b) + c) * d) / e, -}); +export const FUNCTIONS: Record number> = + Object.freeze({ + A: (a: number, b: number, c: number, d: number, e: number) => + ((a + b) * c) / Math.pow(d, e), + B: (a: number, b: number, c: number, d: number, e: number) => + Math.pow(a + b, c) / (d * e), + C: (a: number, b: number, c: number, d: number, e: number) => + a / b + c * Math.pow(d, e), + D: (a: number, b: number, c: number, d: number, e: number) => + (a * b) / Math.pow(c + d, e), + E: (a: number, b: number, c: number, d: number, e: number) => + Math.pow((a + b) / c, d) * e, + F: (a: number, b: number, c: number, d: number, e: number) => + (a * Math.pow(b + c, d)) / e, + G: (a: number, b: number, c: number, d: number, e: number) => + ((Math.pow(a, b) + c) * d) / e, + }); diff --git a/lesson_06/expression/src/lesson6.test.ts b/lesson_06/expression/src/lesson6.test.ts index b222ccd55..5ad2c6820 100644 --- a/lesson_06/expression/src/lesson6.test.ts +++ b/lesson_06/expression/src/lesson6.test.ts @@ -17,7 +17,7 @@ describe("Lesson6Test", () => { const c = 3; const d = 4; const e = 5; - const expected = FUNCTIONS[process.env.HW_VERSION!].call( + const expected = FUNCTIONS[process.env.HW_VERSION || ""].call( null, ...[a, b, c, d, e], ); diff --git a/lesson_06/expression/src/lesson6.ts b/lesson_06/expression/src/lesson6.ts index bfe71e676..00af72421 100644 --- a/lesson_06/expression/src/lesson6.ts +++ b/lesson_06/expression/src/lesson6.ts @@ -13,7 +13,7 @@ const rl = createInterface({ }); const main = async () => { - const testFunction = FUNCTIONS[process.env.HW_VERSION!]; + const testFunction = FUNCTIONS[process.env.HW_VERSION || ""]; if (testFunction === undefined) { console.log("HW_VERSION version not set in config. Exiting..."); process.exit(1); diff --git a/lesson_06/expression/src/utils.ts b/lesson_06/expression/src/utils.ts index e6f53b6a0..520741a62 100644 --- a/lesson_06/expression/src/utils.ts +++ b/lesson_06/expression/src/utils.ts @@ -12,9 +12,9 @@ export const askQuestion = ( }); }; -export const getFunctionBody = (f: Function) => { - const fString = f.toString().split("=>").pop()!; - return beautify(fString); +export const getFunctionBody = (f: () => unknown) => { + const fString = f.toString().split("=>").pop(); + return beautify(fString || ""); }; export const printFormualaWithValues = ( @@ -34,7 +34,7 @@ export const printFormualaWithValues = ( ["e", String(e)], ["pow", "Math.pow"], ).reduce( - (acc: string, param: string[]) => acc.replace(param[0]!, param[1]!), + (acc: string, param: string[]) => acc.replace(param[0], param[1]), functionBody, ); console.log(`\nNow computing the value of ${formula}`); From a0ba9637ded21fd77470dc6e0760b24e2cc13707 Mon Sep 17 00:00:00 2001 From: Dylan Date: Mon, 17 Mar 2025 21:14:34 +0000 Subject: [PATCH 09/11] FEAT: Rewrites Function code to have checks pass. --- .../expression/src/expression_calculator.ts | 19 ++++++++++++++++--- lesson_06/expression/src/lesson6.test.ts | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/lesson_06/expression/src/expression_calculator.ts b/lesson_06/expression/src/expression_calculator.ts index f220ff71e..0b138ebb7 100644 --- a/lesson_06/expression/src/expression_calculator.ts +++ b/lesson_06/expression/src/expression_calculator.ts @@ -1,11 +1,24 @@ 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 (a * this.pow(b + c, d)) / e; + + add(a: number, b: number): number { + return a + b; + } + + multiply(a: number, b: number): number { + return a * b; + } + + divide(a: number, b: number): number { + if (b === 0) throw new Error("Cannot divide by zero"); + return a / b; } pow(base: number, exponent: number): number { return Math.pow(base, exponent); } + + calculate(a: number, b: number, c: number, d: number, e: number): number { + return this.multiply(a, this.divide(this.pow(this.add(b, c), d), e)); + } } diff --git a/lesson_06/expression/src/lesson6.test.ts b/lesson_06/expression/src/lesson6.test.ts index 5ad2c6820..509eb98f5 100644 --- a/lesson_06/expression/src/lesson6.test.ts +++ b/lesson_06/expression/src/lesson6.test.ts @@ -39,7 +39,7 @@ describe("Lesson6Test", () => { test("testAdd_works", () => { // Act - const result = calculator.add(2, 3); + const result = calculator.add(1, 2); // Assert expect(result).toBe(3); From 017de1210df18b4823f59439f742afaa23c1d381 Mon Sep 17 00:00:00 2001 From: Dlafferty251 Date: Tue, 18 Mar 2025 09:16:16 -0400 Subject: [PATCH 10/11] Update lesson5.ts --- lesson_06/quiz/src/lesson5.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lesson_06/quiz/src/lesson5.ts b/lesson_06/quiz/src/lesson5.ts index ddcfa4f50..da063c107 100644 --- a/lesson_06/quiz/src/lesson5.ts +++ b/lesson_06/quiz/src/lesson5.ts @@ -38,7 +38,7 @@ export class Lesson5 { [AnswerChoice.C, "To insert an image"], [AnswerChoice.D, "To create a paragraph"], ]), - AnswerChoice.B, + AnswerChoice.Unanswered, ); } @@ -52,7 +52,7 @@ export class Lesson5 { [AnswerChoice.C, "alt"], [AnswerChoice.D, "href"], ]), - AnswerChoice.C, + AnswerChoice.Unanswered, ); } @@ -66,7 +66,7 @@ export class Lesson5 { [AnswerChoice.C, "
"], [AnswerChoice.D, ""], ]), - AnswerChoice.B, + AnswerChoice.Unanswered, ); } @@ -80,7 +80,7 @@ export class Lesson5 { [AnswerChoice.C, ""], [AnswerChoice.D, "
"], ]), - AnswerChoice.D, + AnswerChoice.Unanswered, ); } @@ -94,7 +94,7 @@ export class Lesson5 { [AnswerChoice.C, "Computer Style Sheets"], [AnswerChoice.D, "Cascading System Sheets"], ]), - AnswerChoice.B, + AnswerChoice.Unanswered, ); } @@ -108,7 +108,7 @@ export class Lesson5 { [AnswerChoice.C, "text-color"], [AnswerChoice.D, "background-color"], ]), - AnswerChoice.B, + AnswerChoice.Unanswered, ); } @@ -122,7 +122,7 @@ export class Lesson5 { [AnswerChoice.C, "/* this is a comment */"], [AnswerChoice.D, ""], ]), - AnswerChoice.C, + AnswerChoice.Unanswered, ); } @@ -136,7 +136,7 @@ export class Lesson5 { [AnswerChoice.C, "text-size"], [AnswerChoice.D, "text-style"], ]), - AnswerChoice.B, + AnswerChoice.Unanswered, ); } @@ -150,7 +150,7 @@ export class Lesson5 { [AnswerChoice.C, "inline-block"], [AnswerChoice.D, "none"], ]), - AnswerChoice.B, + AnswerChoice.Unanswered, ); } @@ -164,7 +164,7 @@ export class Lesson5 { [AnswerChoice.C, ""], [AnswerChoice.D, ""], ]), - AnswerChoice.A, + AnswerChoice.Unanswered, ); } } From 16844e86fd819f67db64ee680b6e0e66598110a1 Mon Sep 17 00:00:00 2001 From: Dlafferty251 Date: Tue, 18 Mar 2025 09:18:08 -0400 Subject: [PATCH 11/11] Update lesson5.ts --- lesson_06/quiz/src/lesson5.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lesson_06/quiz/src/lesson5.ts b/lesson_06/quiz/src/lesson5.ts index da063c107..9ad62bd67 100644 --- a/lesson_06/quiz/src/lesson5.ts +++ b/lesson_06/quiz/src/lesson5.ts @@ -38,7 +38,7 @@ export class Lesson5 { [AnswerChoice.C, "To insert an image"], [AnswerChoice.D, "To create a paragraph"], ]), - AnswerChoice.Unanswered, + AnswerChoice.UNANSWERED, ); } @@ -52,7 +52,7 @@ export class Lesson5 { [AnswerChoice.C, "alt"], [AnswerChoice.D, "href"], ]), - AnswerChoice.Unanswered, + AnswerChoice.UNANSWERED, ); } @@ -66,7 +66,7 @@ export class Lesson5 { [AnswerChoice.C, "
"], [AnswerChoice.D, ""], ]), - AnswerChoice.Unanswered, + AnswerChoice.UNANSWERED, ); } @@ -80,7 +80,7 @@ export class Lesson5 { [AnswerChoice.C, ""], [AnswerChoice.D, "
"], ]), - AnswerChoice.Unanswered, + AnswerChoice.UNANSWERED, ); } @@ -94,7 +94,7 @@ export class Lesson5 { [AnswerChoice.C, "Computer Style Sheets"], [AnswerChoice.D, "Cascading System Sheets"], ]), - AnswerChoice.Unanswered, + AnswerChoice.UNANSWERED, ); } @@ -108,7 +108,7 @@ export class Lesson5 { [AnswerChoice.C, "text-color"], [AnswerChoice.D, "background-color"], ]), - AnswerChoice.Unanswered, + AnswerChoice.UNANSWERED, ); } @@ -122,7 +122,7 @@ export class Lesson5 { [AnswerChoice.C, "/* this is a comment */"], [AnswerChoice.D, ""], ]), - AnswerChoice.Unanswered, + AnswerChoice.UNANSWERED, ); } @@ -136,7 +136,7 @@ export class Lesson5 { [AnswerChoice.C, "text-size"], [AnswerChoice.D, "text-style"], ]), - AnswerChoice.Unanswered, + AnswerChoice.UNANSWERED, ); } @@ -150,7 +150,7 @@ export class Lesson5 { [AnswerChoice.C, "inline-block"], [AnswerChoice.D, "none"], ]), - AnswerChoice.Unanswered, + AnswerChoice.UNANSWERED, ); } @@ -164,7 +164,7 @@ export class Lesson5 { [AnswerChoice.C, ""], [AnswerChoice.D, ""], ]), - AnswerChoice.Unanswered, + AnswerChoice.UNANSWERED, ); } }