From ce76c0b5fb978e55f4becec00641d7e9d9d98bb1 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 21:50:50 +0100 Subject: [PATCH 001/105] add empty lines for better readability in angle type tests --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index cf50f6cad..685253f48 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -10,3 +10,5 @@ test("Classifies right angles", () => { const right = getAngleType(90); assert.equal(right, "Right angle"); }); + + From eb2d17dd8b70f7e4c8fb13e4fb51df787e52c4db Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 22:15:47 +0100 Subject: [PATCH 002/105] =?UTF-8?q?implement=20getAngleType=20function=20t?= =?UTF-8?q?o=20return=20"Right=20angle"=20for=2090=C2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index 8a6fba050..c607966fb 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -16,6 +16,8 @@ // After you have implemented the function, write tests to cover all the cases, and // execute the code to ensure all tests pass. -export function getAngleType(angle) { - // TODO: Implement this function +export function getAngleType(angle){ + if (angle === 90){ + return "Right angle" + } } From 56c856c45cf6ebe002e77fb565e434d062997c7d Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 22:25:12 +0100 Subject: [PATCH 003/105] add test case for classifying acute angles in getAngleType function --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index 685253f48..54b7a02e8 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -11,4 +11,7 @@ test("Classifies right angles", () => { assert.equal(right, "Right angle"); }); - +test("Classifies acute angles", () =>{ + const acute = getAngleType(45); + assert.equal(acute, "Acute angle") +}) \ No newline at end of file From 2e4e5e179ba3853d9972bfbee2f79e90b2b96ac8 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 22:27:13 +0100 Subject: [PATCH 004/105] =?UTF-8?q?implement=20getAngleType=20function=20t?= =?UTF-8?q?o=20return=20"Acute=20angle"=20for=20angles=20between=200=C2=B0?= =?UTF-8?q?=20and=2090=C2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index c607966fb..01cb04b63 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -20,4 +20,9 @@ export function getAngleType(angle){ if (angle === 90){ return "Right angle" } + if (angle > 0 && angle < 90){ + return "Acute angle" + } } + + From fd1f878bab6bc13286d434a6a5b6419c2a0a0e4c Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 22:31:36 +0100 Subject: [PATCH 005/105] add test case for classifying obtuse angles in getAngleType function --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index 54b7a02e8..c4f387b92 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -14,4 +14,9 @@ test("Classifies right angles", () => { test("Classifies acute angles", () =>{ const acute = getAngleType(45); assert.equal(acute, "Acute angle") +}) + +test("Classifies obtuse angle", () => { + const obtuse = getAngleType(140); + assert.equal(obtuse, "Obtuse angle") }) \ No newline at end of file From 67bf79b62c7e66d66ca31df3004b48a271983b51 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 22:33:09 +0100 Subject: [PATCH 006/105] =?UTF-8?q?implement=20getAngleType=20function=20t?= =?UTF-8?q?o=20return=20"Obtuse=20angle"=20for=20angles=20between=2090?= =?UTF-8?q?=C2=B0=20and=20180=C2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index 01cb04b63..34a3735c6 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -23,6 +23,11 @@ export function getAngleType(angle){ if (angle > 0 && angle < 90){ return "Acute angle" } + if (angle > 90 && angle < 180){ + return "Obtuse angle" + } } + + From b1a6630df60ff96d95f40bd19ef7785e785d96bf Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 22:41:46 +0100 Subject: [PATCH 007/105] add test case for classifying straight angles in getAngleType function --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index c4f387b92..58bd85627 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -19,4 +19,9 @@ test("Classifies acute angles", () =>{ test("Classifies obtuse angle", () => { const obtuse = getAngleType(140); assert.equal(obtuse, "Obtuse angle") +}) + +test("Classifies straight angle", () => { + const straight = getAngleType(180); + assert.equal(straight, "Straight") }) \ No newline at end of file From db4a27e1fef3164c34e50bbc0f538af92c9c6218 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 22:45:17 +0100 Subject: [PATCH 008/105] fix: correct expected output for straight angle classification test --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index 58bd85627..564c37b0e 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -23,5 +23,5 @@ test("Classifies obtuse angle", () => { test("Classifies straight angle", () => { const straight = getAngleType(180); - assert.equal(straight, "Straight") + assert.equal(straight, "Straight angle") }) \ No newline at end of file From 7e8ad2fbcfdecc71bd9e68d06f58bee902871b58 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 22:45:25 +0100 Subject: [PATCH 009/105] =?UTF-8?q?fix:=20return=20"Straight=20angle"=20fo?= =?UTF-8?q?r=20angle=20equal=20to=20180=C2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index 34a3735c6..3edd7955e 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -26,6 +26,9 @@ export function getAngleType(angle){ if (angle > 90 && angle < 180){ return "Obtuse angle" } + if (angle === 180){ + return "Straight angle" + } } From eeb2846318ce4bd68db2109db89613975f9798fc Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 22:47:57 +0100 Subject: [PATCH 010/105] add test case for classifying reflex angles in getAngleType function --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index 564c37b0e..fcb9648e4 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -24,4 +24,9 @@ test("Classifies obtuse angle", () => { test("Classifies straight angle", () => { const straight = getAngleType(180); assert.equal(straight, "Straight angle") +}) + +test("Classifies reflex angle", () => { + const reflex = getAngleType(250) + assert.equal(reflex, "Reflex angle") }) \ No newline at end of file From 1807a2d6a7ace41081bb9c6d1178440083c4973e Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 22:50:04 +0100 Subject: [PATCH 011/105] fix: add missing semicolons in getAngleType function --- .../implement/1-get-angle-type.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index 3edd7955e..d35e40b41 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -18,16 +18,19 @@ export function getAngleType(angle){ if (angle === 90){ - return "Right angle" + return "Right angle"; } if (angle > 0 && angle < 90){ - return "Acute angle" + return "Acute angle"; } if (angle > 90 && angle < 180){ - return "Obtuse angle" + return "Obtuse angle"; } if (angle === 180){ - return "Straight angle" + return "Straight angle"; + } + if (angle >180 && angle < 360){ + return "Reflex angle"; } } From ad85b141b34cd70e1f3d44d59a77164f35dd408e Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 22:50:40 +0100 Subject: [PATCH 012/105] fix: add missing semicolons and correct test syntax in angle classification tests --- .../1-get-angle-type.test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index fcb9648e4..15b539c38 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -14,19 +14,19 @@ test("Classifies right angles", () => { test("Classifies acute angles", () =>{ const acute = getAngleType(45); assert.equal(acute, "Acute angle") -}) +}); test("Classifies obtuse angle", () => { const obtuse = getAngleType(140); assert.equal(obtuse, "Obtuse angle") -}) +}); test("Classifies straight angle", () => { const straight = getAngleType(180); assert.equal(straight, "Straight angle") -}) +}); test("Classifies reflex angle", () => { const reflex = getAngleType(250) - assert.equal(reflex, "Reflex angle") -}) \ No newline at end of file + assert.equal(reflex, "Reflex angle"); +}); \ No newline at end of file From 325a7ee534635ba53d866251872a95fc41368260 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 22:59:01 +0100 Subject: [PATCH 013/105] fix: add missing semicolons and format test cases in angle classification tests --- .../1-get-angle-type.test.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index 15b539c38..1395c13fc 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -7,26 +7,37 @@ import { getAngleType } from "../implement/1-get-angle-type.js"; // Example: Identify Right Angles test("Classifies right angles", () => { + const right = getAngleType(90); assert.equal(right, "Right angle"); }); test("Classifies acute angles", () =>{ + const acute = getAngleType(45); - assert.equal(acute, "Acute angle") + assert.equal(acute, "Acute angle"); }); test("Classifies obtuse angle", () => { + const obtuse = getAngleType(140); - assert.equal(obtuse, "Obtuse angle") + assert.equal(obtuse, "Obtuse angle"); }); test("Classifies straight angle", () => { + const straight = getAngleType(180); - assert.equal(straight, "Straight angle") + assert.equal(straight, "Straight angle"); }); test("Classifies reflex angle", () => { - const reflex = getAngleType(250) + + const reflex = getAngleType(250); assert.equal(reflex, "Reflex angle"); +}); + +test("Classifies invalid angle", () => { + + assert.equal(getAngleType("0"), "Invalid angle"); + assert.equal(getAngleType("365"), "Invalid angle"); }); \ No newline at end of file From 2d57566ab1ea419850426464eb5bc9c573bb5471 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:09:33 +0100 Subject: [PATCH 014/105] fix: update invalid angle classification in getAngleType function --- implement-and-rewrite-tests/implement/1-get-angle-type.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index d35e40b41..9a1b1b16b 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -31,8 +31,9 @@ export function getAngleType(angle){ } if (angle >180 && angle < 360){ return "Reflex angle"; + } else + return "Invalid angle" } -} From 69af44c822063b6e10ed93878b9abd3a42bbcb45 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:09:38 +0100 Subject: [PATCH 015/105] fix: update invalid angle test case in getAngleType function --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index 1395c13fc..ab665221b 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -38,6 +38,6 @@ test("Classifies reflex angle", () => { test("Classifies invalid angle", () => { - assert.equal(getAngleType("0"), "Invalid angle"); + assert.equal(getAngleType("-1"), "Invalid angle"); assert.equal(getAngleType("365"), "Invalid angle"); }); \ No newline at end of file From 3eb08135ef19903456eccb8631839188e533e1b9 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:17:24 +0100 Subject: [PATCH 016/105] feat: implement isProperFraction function to evaluate proper fractions --- .../implement/2-is-proper-fraction.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js index f983800f0..99cb071f9 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -14,5 +14,9 @@ // execute the code to ensure all tests pass. export function isProperFraction(numerator, denominator) { - // TODO: Implement this function + if (numerator > denominator){ + return "True" + } else { + return "False" + } } From 41d025e52e346337131ed818c9a21ac4c4d141f9 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:27:01 +0100 Subject: [PATCH 017/105] fix: correct isProperFraction logic to return boolean values --- .../implement/2-is-proper-fraction.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js index 99cb071f9..47c802712 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -14,9 +14,7 @@ // execute the code to ensure all tests pass. export function isProperFraction(numerator, denominator) { - if (numerator > denominator){ - return "True" - } else { - return "False" + if (numerator <= denominator){ + return "true" } } From 115eb019f9ed15d41ef4e6c51e4555721bafea17 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:27:08 +0100 Subject: [PATCH 018/105] fix: correct assertion in isProperFraction test to match expected boolean value --- .../2-is-proper-fraction.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js index a29084605..40b6dac92 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js @@ -7,6 +7,6 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js"; // What combinations of numerators and denominators should you test? test("Basic proper fraction", () => { - // Example: 1/2 is a proper fraction - assert.equal(isProperFraction(1, 2), true); + + assert.equal(isProperFraction(1, 2), "true"); }); From e029b5af5a1bfda961baa117337e147c08e316bb Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:29:53 +0100 Subject: [PATCH 019/105] fix: correct return value in isProperFraction function to return boolean true --- .../implement-tests-with-node-test/2-is-proper-fraction.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js index 40b6dac92..35983f952 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js @@ -8,5 +8,5 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js"; test("Basic proper fraction", () => { - assert.equal(isProperFraction(1, 2), "true"); + assert.equal(isProperFraction(1, 2), true); }); From 55d9b0f6a14fb5a620aa8e5e5538369bc0157c57 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:29:59 +0100 Subject: [PATCH 020/105] fix: return boolean true in isProperFraction function instead of string --- implement-and-rewrite-tests/implement/2-is-proper-fraction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js index 47c802712..ad9cfb68c 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -15,6 +15,6 @@ export function isProperFraction(numerator, denominator) { if (numerator <= denominator){ - return "true" + return true } } From 09732da58e8b0960d7477afa62f04c5edeee4b3c Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:32:35 +0100 Subject: [PATCH 021/105] fix: update isProperFraction logic to correctly evaluate proper fractions --- .../implement/2-is-proper-fraction.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js index ad9cfb68c..981422f65 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -14,7 +14,11 @@ // execute the code to ensure all tests pass. export function isProperFraction(numerator, denominator) { - if (numerator <= denominator){ + if (numerator < denominator){ return true } + if (numerator > denominator){ + return false + } + } From 268b7e44daff7f458aa59ef7e78aebc2de441fd2 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:32:41 +0100 Subject: [PATCH 022/105] test: add assertion for improper fraction case in isProperFraction test --- .../implement-tests-with-node-test/2-is-proper-fraction.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js index 35983f952..9c25a74fe 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js @@ -9,4 +9,5 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js"; test("Basic proper fraction", () => { assert.equal(isProperFraction(1, 2), true); + assert.equal(isProperFraction(2, 1), false) }); From f02a167c3e23972f24df133b5fc13d65bd796f88 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:40:15 +0100 Subject: [PATCH 023/105] test: add additional test cases for isProperFraction function --- .../implement/2-is-proper-fraction.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js index 981422f65..cb8e2463e 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -20,5 +20,8 @@ export function isProperFraction(numerator, denominator) { if (numerator > denominator){ return false } - + if (-numerator < denominator){ + return true + } } + console.log(isProperFraction(-2, 1)) From f42344511be7698f796e85e3adc1bcbe45e482d4 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:40:20 +0100 Subject: [PATCH 024/105] test: add assertion for negative numerator case in isProperFraction test --- .../2-is-proper-fraction.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js index 9c25a74fe..72ceae6f8 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js @@ -9,5 +9,6 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js"; test("Basic proper fraction", () => { assert.equal(isProperFraction(1, 2), true); - assert.equal(isProperFraction(2, 1), false) + assert.equal(isProperFraction(2, 1), false); + assert.equal(isProperFraction(-2, 1), true); }); From 3f5bc580dba0593687f360d5360b42883929c077 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:41:33 +0100 Subject: [PATCH 025/105] test: add assertion for negative denominator case in isProperFraction test --- .../implement-tests-with-node-test/2-is-proper-fraction.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js index 72ceae6f8..c843d5eb9 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js @@ -11,4 +11,5 @@ test("Basic proper fraction", () => { assert.equal(isProperFraction(1, 2), true); assert.equal(isProperFraction(2, 1), false); assert.equal(isProperFraction(-2, 1), true); + assert.equal(isProperFraction(1, -2), false); }); From 388bb92292baafa0020e6cc7042633e47b9e8785 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:54:26 +0100 Subject: [PATCH 026/105] fix: refine isProperFraction logic to handle negative numerator and denominator cases --- .../implement/2-is-proper-fraction.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js index cb8e2463e..1f055a125 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -23,5 +23,8 @@ export function isProperFraction(numerator, denominator) { if (-numerator < denominator){ return true } + if (numerator > -denominator){ + return false + } } - console.log(isProperFraction(-2, 1)) + From addec7e6d1d21659ac3203afaa59622d10731eb3 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:55:05 +0100 Subject: [PATCH 027/105] refactor: remove unnecessary blank line in isProperFraction test --- .../implement-tests-with-node-test/2-is-proper-fraction.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js index c843d5eb9..7e4a77c4b 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js @@ -7,7 +7,6 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js"; // What combinations of numerators and denominators should you test? test("Basic proper fraction", () => { - assert.equal(isProperFraction(1, 2), true); assert.equal(isProperFraction(2, 1), false); assert.equal(isProperFraction(-2, 1), true); From 7b32fd3d095e41760e3b2ec255269a7ea5dd0e67 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:55:27 +0100 Subject: [PATCH 028/105] refactor: improve formatting and consistency in isProperFraction function --- .../implement/2-is-proper-fraction.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js index 1f055a125..8a19861b7 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -14,17 +14,16 @@ // execute the code to ensure all tests pass. export function isProperFraction(numerator, denominator) { - if (numerator < denominator){ - return true + if (numerator < denominator) { + return true; } - if (numerator > denominator){ - return false + if (numerator > denominator) { + return false; } - if (-numerator < denominator){ - return true + if (-numerator < denominator) { + return true; } - if (numerator > -denominator){ - return false + if (numerator > -denominator) { + return false; } } - From 3007cee68975acc71312adc99970b49914e651db Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:56:38 +0100 Subject: [PATCH 029/105] refactor: remove unnecessary comments from isProperFraction implementation --- .../implement/2-is-proper-fraction.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js index 8a19861b7..a82377e77 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -1,18 +1,3 @@ -// Implement a function isProperFraction, -// -// Don't forget to write tests in implement-tests-with-node-test. -// -// When given two numbers, a numerator and a denominator, it should return true if -// the given numbers form a proper fraction, and false otherwise. - -// Assumption: The parameters are valid numbers (not NaN or Infinity). - -// Note: If you are unfamiliar with proper fractions, please look up its mathematical definition. - -// Acceptance criteria: -// After you have implemented the function, write tests to cover all the cases, and -// execute the code to ensure all tests pass. - export function isProperFraction(numerator, denominator) { if (numerator < denominator) { return true; From 7335f6123ca3b04dfa3b1cc1cc690846e4404e48 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 8 Oct 2026 23:57:43 +0100 Subject: [PATCH 030/105] refactor: remove TODO comments from isProperFraction test file --- .../2-is-proper-fraction.test.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js index 7e4a77c4b..d5d4edd2d 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/2-is-proper-fraction.test.js @@ -3,9 +3,6 @@ import test from "node:test"; import { isProperFraction } from "../implement/2-is-proper-fraction.js"; -// TODO: Write tests to cover all cases. -// What combinations of numerators and denominators should you test? - test("Basic proper fraction", () => { assert.equal(isProperFraction(1, 2), true); assert.equal(isProperFraction(2, 1), false); From fd4c2d8a971e840a99e62a52e8771f296c9003fd Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 07:57:24 +0100 Subject: [PATCH 031/105] refactor: comment out unused test cases and implement basic getCardValue logic for Ace --- .../3-get-card-value.test.js | 14 +++++++++----- .../implement/3-get-card-value.js | 6 +++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index f5092d9b1..e85626462 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -5,12 +5,16 @@ import { getCardValue } from "../implement/3-get-card-value.js"; // TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. -test("Valid single-digit card", () => { - assert.equal(getCardValue("9♠"), 9); -}); +// test("Valid single-digit card", () => { +// assert.equal(getCardValue("9♠"), 9); +// }); -test("Arbitrary non-card string", () => { - assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); +test("Ace card returns 11", () => { + assert.equal(getCardValue("A♠"), 11); }); +// test("Arbitrary non-card string", () => { +// assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); +// }); + // TODO: What other invalid card cases can you think of? diff --git a/implement-and-rewrite-tests/implement/3-get-card-value.js b/implement-and-rewrite-tests/implement/3-get-card-value.js index 9614ab1ee..9cbfc8735 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -24,5 +24,9 @@ // execute the code to ensure all tests pass. export function getCardValue(card) { - // TODO: Implement this function + const suit = card.slice(-1); + const rank = card.slice(0, -1); + if (rank === "A"){ + return 11 + } } From 3ff46c74b16fbce26917fcee4e47a8f40496146d Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 08:00:07 +0100 Subject: [PATCH 032/105] refactor: uncomment valid single-digit card test in getCardValue test suite --- .../implement-tests-with-node-test/3-get-card-value.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index e85626462..c3f09cd3b 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -5,9 +5,9 @@ import { getCardValue } from "../implement/3-get-card-value.js"; // TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. -// test("Valid single-digit card", () => { -// assert.equal(getCardValue("9♠"), 9); -// }); +test("Valid single-digit card", () => { + assert.equal(getCardValue("9♠"), 9); +}); test("Ace card returns 11", () => { assert.equal(getCardValue("A♠"), 11); From 9f2028058454a68390bc4a91fabaf198ad82d806 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 08:00:19 +0100 Subject: [PATCH 033/105] refactor: fix getCardValue function to return numeric value for number cards --- implement-and-rewrite-tests/implement/3-get-card-value.js | 1 + 1 file changed, 1 insertion(+) diff --git a/implement-and-rewrite-tests/implement/3-get-card-value.js b/implement-and-rewrite-tests/implement/3-get-card-value.js index 9cbfc8735..cfd920853 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -29,4 +29,5 @@ export function getCardValue(card) { if (rank === "A"){ return 11 } + return Number(rank) } From 92c9dd3d16c01eeac63cd68712345a7486875454 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 08:06:36 +0100 Subject: [PATCH 034/105] refactor: add test for face cards to return correct value --- .../implement-tests-with-node-test/3-get-card-value.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index c3f09cd3b..dd3438fa0 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -13,6 +13,9 @@ test("Ace card returns 11", () => { assert.equal(getCardValue("A♠"), 11); }); +test("Face cards returns 10", () => { + assert.equal(getCardValue("J", "Q", "K"), 10) +}) // test("Arbitrary non-card string", () => { // assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); // }); From 08a8dac699eaa27933a868d21e55346e8b02eba6 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 08:12:56 +0100 Subject: [PATCH 035/105] refactor: fix face card test cases to use correct syntax for getCardValue --- .../implement-tests-with-node-test/3-get-card-value.test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index dd3438fa0..0db922a94 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -14,8 +14,10 @@ test("Ace card returns 11", () => { }); test("Face cards returns 10", () => { - assert.equal(getCardValue("J", "Q", "K"), 10) -}) + assert.equal(getCardValue("J♣"), 10); + assert.equal(getCardValue("Q♦"), 10); + assert.equal(getCardValue("K♥"), 10); +}); // test("Arbitrary non-card string", () => { // assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); // }); From 5422d781bc58d2e36afd448f21e3133afbdc0967 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 08:13:06 +0100 Subject: [PATCH 036/105] refactor: fix formatting and structure in getCardValue function for clarity --- .../implement/3-get-card-value.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/implement-and-rewrite-tests/implement/3-get-card-value.js b/implement-and-rewrite-tests/implement/3-get-card-value.js index cfd920853..11288670a 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -27,7 +27,10 @@ export function getCardValue(card) { const suit = card.slice(-1); const rank = card.slice(0, -1); if (rank === "A"){ - return 11 - } - return Number(rank) -} + return 11; + }; + if (rank === "J" || rank === "Q" || rank === "K"){ + return 10; + }; + return Number(rank); +}; From ab0f20e042b4ebdb89b13dbbef093a922035c4d2 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 08:51:24 +0100 Subject: [PATCH 037/105] refactor: uncomment test for arbitrary non-card string and enhance error handling in getCardValue function --- .../3-get-card-value.test.js | 6 +++--- implement-and-rewrite-tests/implement/3-get-card-value.js | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index 0db922a94..4c16408a4 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -18,8 +18,8 @@ test("Face cards returns 10", () => { assert.equal(getCardValue("Q♦"), 10); assert.equal(getCardValue("K♥"), 10); }); -// test("Arbitrary non-card string", () => { -// assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); -// }); +test("Arbitrary non-card string", () => { + assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); +}); // TODO: What other invalid card cases can you think of? diff --git a/implement-and-rewrite-tests/implement/3-get-card-value.js b/implement-and-rewrite-tests/implement/3-get-card-value.js index 11288670a..3c6601543 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -26,6 +26,13 @@ export function getCardValue(card) { const suit = card.slice(-1); const rank = card.slice(0, -1); + + const validSuit = ["♠", "♥", "♦", "♣"]; + const validRank = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]; + + if (!validSuit.includes(suit) || !validRank.includes(rank)){ + throw new Error (`Expected a number followed by a suit, but got "${card}"`); + }; if (rank === "A"){ return 11; }; From 0ac8992dbf89c98e7b66c5a57df540f1fe0ca55f Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 08:57:58 +0100 Subject: [PATCH 038/105] refactor: add newline at the end of 3-get-card-value.js for consistency --- implement-and-rewrite-tests/implement/3-get-card-value.js | 1 + 1 file changed, 1 insertion(+) diff --git a/implement-and-rewrite-tests/implement/3-get-card-value.js b/implement-and-rewrite-tests/implement/3-get-card-value.js index 3c6601543..fc5d19db1 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -41,3 +41,4 @@ export function getCardValue(card) { }; return Number(rank); }; + From 95460606ee3ab9bdc6456fa7dd00b2130bf68e4c Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 08:58:58 +0100 Subject: [PATCH 039/105] refactor: clean up comments and improve formatting in getCardValue function --- .../implement/3-get-card-value.js | 60 ++++++++----------- 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/implement-and-rewrite-tests/implement/3-get-card-value.js b/implement-and-rewrite-tests/implement/3-get-card-value.js index fc5d19db1..5a1a1a762 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -1,44 +1,32 @@ -// This problem involves playing cards: https://en.wikipedia.org/wiki/Standard_52-card_deck - -// Don't forget to write tests in implement-tests-with-node-test. - -// Implement a function getCardValue, when given a string representing a playing card, -// should return the numerical value of the card. - -// A valid card string will contain a rank followed by the suit. -// The rank can be one of the following strings: -// "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" -// The suit can be one of the following emojis: -// "♠", "♥", "♦", "♣" -// For example: "A♠", "2♥", "10♥", "J♣", "Q♦", "K♦". - -// When the card is an ace ("A"), the function should return 11. -// When the card is a face card ("J", "Q", "K"), the function should return 10. -// When the card is a number card ("2" to "10"), the function should return its numeric value. - -// When the card string is invalid (not following the above format), the function should -// throw an error. - -// Acceptance criteria: -// After you have implemented the function, write tests to cover all the cases, and -// execute the code to ensure all tests pass. - export function getCardValue(card) { const suit = card.slice(-1); const rank = card.slice(0, -1); const validSuit = ["♠", "♥", "♦", "♣"]; - const validRank = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]; - - if (!validSuit.includes(suit) || !validRank.includes(rank)){ - throw new Error (`Expected a number followed by a suit, but got "${card}"`); - }; - if (rank === "A"){ + const validRank = [ + "A", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "J", + "Q", + "K", + ]; + + if (!validSuit.includes(suit) || !validRank.includes(rank)) { + throw new Error(`Expected a number followed by a suit, but got "${card}"`); + } + if (rank === "A") { return 11; - }; - if (rank === "J" || rank === "Q" || rank === "K"){ + } + if (rank === "J" || rank === "Q" || rank === "K") { return 10; - }; + } return Number(rank); -}; - +} From 310b716a01f9a6d4b4263d3dc25353278ce46e9d Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 08:59:56 +0100 Subject: [PATCH 040/105] refactor: remove TODO comments and improve formatting in test cases for getCardValue function --- .../3-get-card-value.test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index 4c16408a4..436b3091c 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -3,8 +3,6 @@ import test from "node:test"; import { getCardValue } from "../implement/3-get-card-value.js"; -// TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. - test("Valid single-digit card", () => { assert.equal(getCardValue("9♠"), 9); }); @@ -19,7 +17,9 @@ test("Face cards returns 10", () => { assert.equal(getCardValue("K♥"), 10); }); test("Arbitrary non-card string", () => { - assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); + assert.throws( + () => getCardValue("invalid"), + /Expected a number followed by a suit, but got "invalid"/, + "Expected clear error" + ); }); - -// TODO: What other invalid card cases can you think of? From cd6cf1e30be7855d4f0be7916bd76514e0fff268 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 09:40:47 +0100 Subject: [PATCH 041/105] refactor: add additional test cases for card value validation and error handling --- .../3-get-card-value.test.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index 436b3091c..a17ae73e3 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -23,3 +23,31 @@ test("Arbitrary non-card string", () => { "Expected clear error" ); }); + +test("Negative values string", () => { + assert.throws( + () => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, + "Expected clear error" + ); +}); + +test("Lowercase ranks", () => { + assert.equal(getCardValue("a♦"), 11); + assert.equal(getCardValue("j♦"), 10); +}); + +test("Missing or broken suit", () => { + assert.throws( + () => getCardValue("9"), /Expected/ + ); + assert.throws( + () => getValues(""), /Expected/ + ); +}); + +test("Two digit rank", () => { + assert.equal(getCardValue("10♦"), 10); +}); + + + From c08bc7b754d5a390c8cc4162363c7459dc1060be Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 09:43:39 +0100 Subject: [PATCH 042/105] refactor: add test case for handling extra characters in card input --- .../implement-tests-with-node-test/3-get-card-value.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index a17ae73e3..2df8332f3 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -49,5 +49,8 @@ test("Two digit rank", () => { assert.equal(getCardValue("10♦"), 10); }); - +test("Adding junks with extra character", ()=> { + assert.throws(getCardValue("9♦y"), /Expected/ +); +}); From 23f8f8d94af389849252c9526a5811e825a1e37c Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 09:52:28 +0100 Subject: [PATCH 043/105] refactor: improve formatting in missing or broken suit test cases --- .../implement-tests-with-node-test/3-get-card-value.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index 2df8332f3..18e94f7c6 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -38,10 +38,10 @@ test("Lowercase ranks", () => { test("Missing or broken suit", () => { assert.throws( - () => getCardValue("9"), /Expected/ + () => (getCardValue("9")), /Expected/ ); assert.throws( - () => getValues(""), /Expected/ + () => (getCardValue("")), /Expected/ ); }); From 732e5ac26f23f9b21773de4f6716fbb2096e75cd Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 09:52:35 +0100 Subject: [PATCH 044/105] refactor: ensure rank is consistently uppercased in getCardValue function --- implement-and-rewrite-tests/implement/3-get-card-value.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement/3-get-card-value.js b/implement-and-rewrite-tests/implement/3-get-card-value.js index 5a1a1a762..3ecf2844c 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -1,6 +1,6 @@ export function getCardValue(card) { const suit = card.slice(-1); - const rank = card.slice(0, -1); + const rank = card.slice(0, -1).toUpperCase(); const validSuit = ["♠", "♥", "♦", "♣"]; const validRank = [ @@ -30,3 +30,5 @@ export function getCardValue(card) { } return Number(rank); } + + From 3b3d1564374238c7583d1167319c8fff3e742fa7 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 09:58:23 +0100 Subject: [PATCH 045/105] refactor: fix syntax in test case for handling extra characters in card input --- .../implement-tests-with-node-test/3-get-card-value.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index 18e94f7c6..0203d28b3 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -49,8 +49,8 @@ test("Two digit rank", () => { assert.equal(getCardValue("10♦"), 10); }); -test("Adding junks with extra character", ()=> { - assert.throws(getCardValue("9♦y"), /Expected/ +test("Adding junks with extra character", () => { + () => assert.throws(getCardValue("9♦y"), /Expected/ ); }); From cdb038b14bdf3defe8a0e53a40f46eb7817e7982 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 10:03:38 +0100 Subject: [PATCH 046/105] refactor: fix syntax error in test case for handling extra characters in card input --- .../implement-tests-with-node-test/3-get-card-value.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index 0203d28b3..38f3ff414 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -52,5 +52,5 @@ test("Two digit rank", () => { test("Adding junks with extra character", () => { () => assert.throws(getCardValue("9♦y"), /Expected/ ); -}); +); From 5d45a2087657591fccb9a0d48481e001c081748a Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 10:05:14 +0100 Subject: [PATCH 047/105] refactor: fix syntax error in test case for adding junk characters to card input --- .../implement-tests-with-node-test/3-get-card-value.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js index 38f3ff414..0203d28b3 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/3-get-card-value.test.js @@ -52,5 +52,5 @@ test("Two digit rank", () => { test("Adding junks with extra character", () => { () => assert.throws(getCardValue("9♦y"), /Expected/ ); -); +}); From 362a572288e81b78dee2a2e67275db399d1818e5 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 10:47:50 +0100 Subject: [PATCH 048/105] refactor: add test case for right angle in getAngleType function --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index e0ba786ab..0acbd3eb7 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -11,6 +11,13 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { expect(getAngleType(89)).toEqual("Acute angle"); }); +test(`Should return "Right angle" when (angle === 90)`, () => { + expect(getAngleType(90)).toEqual("Right angle"); +}) + + + + // Case 2: Right angle // Case 3: Obtuse angles // Case 4: Straight angle From 34bd7f80b8c3c6165acb64d261766ac869d8daa2 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 11:04:48 +0100 Subject: [PATCH 049/105] refactor: add test case for obtuse angles in getAngleType function --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index 0acbd3eb7..d0bd29436 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -13,7 +13,15 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { test(`Should return "Right angle" when (angle === 90)`, () => { expect(getAngleType(90)).toEqual("Right angle"); -}) +}); + +test(`Should return "Obtuse Angle" when (angle > 90 and angle < 180)`, () => { + expect(getAngleType(91)).toEqual("Obtuse angle"); + expect(getAngleType(120)).toEqual("Obtuse angle"); + expect(getAngleType(170)).toEqual("Obtuse angle"); +}); + + From 068bdef75eab15bcf41e9d2750b482a98102f154 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 11:05:11 +0100 Subject: [PATCH 050/105] refactor: add test case for straight angle in getAngleType function --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index d0bd29436..06694bfa1 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -21,6 +21,10 @@ test(`Should return "Obtuse Angle" when (angle > 90 and angle < 180)`, () => { expect(getAngleType(170)).toEqual("Obtuse angle"); }); +test(`Should return "Straight angle" when (angle === 180)`, () => { + expect(getAngleType(180)).toEqual("Straight angle") +}) + From 2c43396ecbe1f2080bee0b1f2ed0efaafdd4ef3d Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 11:12:44 +0100 Subject: [PATCH 051/105] refactor: add tests for reflex and invalid angles in getAngleType function --- .../1-get-angle-type.test.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index 06694bfa1..cbd691381 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -22,9 +22,19 @@ test(`Should return "Obtuse Angle" when (angle > 90 and angle < 180)`, () => { }); test(`Should return "Straight angle" when (angle === 180)`, () => { - expect(getAngleType(180)).toEqual("Straight angle") -}) + expect(getAngleType(180)).toEqual("Straight angle"); +}); +test(`Should return "Reflex angle" when (angle > 180 and angle < 360)`, () => { + expect(getAngleType(181)).toEqual("Reflex angle"); + expect(getAngleType(195)).toEqual("Reflex angle"); + expect(getAngleType(290)).toEqual("Reflex angle"); +}); + +test(`Should return "Invalid angle when (angle < 0 and angle > 360)`, () => { + expect(getAngleType(-1)).toEqual("Invalid angle"); + expect(getAngleType(361)).toEqual("Invalid angle") +}) From d478206e58f1197d92cab4ec8ae4488bd0dff959 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 12:02:47 +0100 Subject: [PATCH 052/105] refactor: add additional test cases for invalid angles in getAngleType function --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index cbd691381..d91c70465 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -33,8 +33,10 @@ test(`Should return "Reflex angle" when (angle > 180 and angle < 360)`, () => { test(`Should return "Invalid angle when (angle < 0 and angle > 360)`, () => { expect(getAngleType(-1)).toEqual("Invalid angle"); - expect(getAngleType(361)).toEqual("Invalid angle") -}) + expect(getAngleType(361)).toEqual("Invalid angle"); + expect(getAngleType(0)).toEqual("Invalid angle"); + expect(getAngleType(360)).toEqual("Invalid angle"); +}); From 94d3efb2a7c7cadd19ee1815f60b5997291c0cd0 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 12:05:38 +0100 Subject: [PATCH 053/105] refactor: remove unnecessary whitespace in getAngleType test file --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index d91c70465..ab3e6a135 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -38,10 +38,6 @@ test(`Should return "Invalid angle when (angle < 0 and angle > 360)`, () => { expect(getAngleType(360)).toEqual("Invalid angle"); }); - - - - // Case 2: Right angle // Case 3: Obtuse angles // Case 4: Straight angle From a9c25bfac56db3cc3ad8974a6eae87fc8dd2b17f Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 12:06:01 +0100 Subject: [PATCH 054/105] refactor: remove commented-out cases in getAngleType test file --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index ab3e6a135..f4e38c28b 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -37,9 +37,3 @@ test(`Should return "Invalid angle when (angle < 0 and angle > 360)`, () => { expect(getAngleType(0)).toEqual("Invalid angle"); expect(getAngleType(360)).toEqual("Invalid angle"); }); - -// Case 2: Right angle -// Case 3: Obtuse angles -// Case 4: Straight angle -// Case 5: Reflex angles -// Case 6: Invalid angles From 0297184a6d337dafeb9dec4408d270310fb1f443 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 12:07:05 +0100 Subject: [PATCH 055/105] refactor: clean up whitespace and comments in getAngleType test file --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index f4e38c28b..74c0d87fe 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -5,33 +5,38 @@ import { getAngleType } from "../implement/1-get-angle-type.js"; // Case 1: Acute angles test(`should return "Acute angle" when (0 < angle < 90)`, () => { - // Test various acute angles, including boundary cases + expect(getAngleType(1)).toEqual("Acute angle"); expect(getAngleType(45)).toEqual("Acute angle"); expect(getAngleType(89)).toEqual("Acute angle"); }); test(`Should return "Right angle" when (angle === 90)`, () => { + expect(getAngleType(90)).toEqual("Right angle"); }); test(`Should return "Obtuse Angle" when (angle > 90 and angle < 180)`, () => { + expect(getAngleType(91)).toEqual("Obtuse angle"); expect(getAngleType(120)).toEqual("Obtuse angle"); expect(getAngleType(170)).toEqual("Obtuse angle"); }); test(`Should return "Straight angle" when (angle === 180)`, () => { + expect(getAngleType(180)).toEqual("Straight angle"); }); test(`Should return "Reflex angle" when (angle > 180 and angle < 360)`, () => { + expect(getAngleType(181)).toEqual("Reflex angle"); expect(getAngleType(195)).toEqual("Reflex angle"); expect(getAngleType(290)).toEqual("Reflex angle"); }); test(`Should return "Invalid angle when (angle < 0 and angle > 360)`, () => { + expect(getAngleType(-1)).toEqual("Invalid angle"); expect(getAngleType(361)).toEqual("Invalid angle"); expect(getAngleType(0)).toEqual("Invalid angle"); From a4aed0f3606b989686a21adc53a2087996994352 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 12:47:07 +0100 Subject: [PATCH 056/105] test: add test case for negative denominator in isProperFraction function --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 5d49e2d8b..b70651cce 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -6,3 +6,8 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js"; test(`should return false when denominator is zero`, () => { expect(isProperFraction(1, 0)).toEqual(false); }); + +test(`Should return false when denominator is negative`, () => { + expect(isProperFraction(1, -2)).toEqual(false); +}); + From 9249f9a6027635785e7a82a0f59eb40d6cb942ea Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 12:47:39 +0100 Subject: [PATCH 057/105] test: add test case for valid denominator in isProperFraction function --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index b70651cce..fdf683e07 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -11,3 +11,7 @@ test(`Should return false when denominator is negative`, () => { expect(isProperFraction(1, -2)).toEqual(false); }); +test(`Should return true when denominator is >`, () => { + expect(isProperFraction(1, 2)).toEqual(true); +}); + From c96b8e8cb02676efad44b5337a9b074961316f23 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 12:48:08 +0100 Subject: [PATCH 058/105] test: add test case for zero numerator in isProperFraction function --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index fdf683e07..9a2e2adab 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -15,3 +15,7 @@ test(`Should return true when denominator is >`, () => { expect(isProperFraction(1, 2)).toEqual(true); }); +test(`Should return true when numerator is zero`, ()=> { + expect(isProperFraction(0, 4)).toEqual(true); +}); + From 71fad6878f88d554f263388891164af067c5e484 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 12:48:25 +0100 Subject: [PATCH 059/105] test: add test case for equality of numerator and denominator in isProperFraction function --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 9a2e2adab..16e93c431 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -19,3 +19,6 @@ test(`Should return true when numerator is zero`, ()=> { expect(isProperFraction(0, 4)).toEqual(true); }); +test(`Should return false when numerator === denominator`, () => { + expect(isProperFraction(5, 5)).toEqual(false); +}); \ No newline at end of file From bc356fbbe2dbc81779382c77daef427319e0963d Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 12:51:09 +0100 Subject: [PATCH 060/105] test: clarify test description for proper fraction denominator comparison --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 16e93c431..7b022a4b3 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -11,7 +11,7 @@ test(`Should return false when denominator is negative`, () => { expect(isProperFraction(1, -2)).toEqual(false); }); -test(`Should return true when denominator is >`, () => { +test(`Should return true when denominator is > numerator`, () => { expect(isProperFraction(1, 2)).toEqual(true); }); @@ -21,4 +21,4 @@ test(`Should return true when numerator is zero`, ()=> { test(`Should return false when numerator === denominator`, () => { expect(isProperFraction(5, 5)).toEqual(false); -}); \ No newline at end of file +}); From 02239f4ee3e744f717d30061704ea4c258c7e05b Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 13:20:55 +0100 Subject: [PATCH 061/105] fix: ensure proper fraction logic handles equality of numerator and denominator --- implement-and-rewrite-tests/implement/2-is-proper-fraction.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js index a82377e77..4b8d8cadd 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -5,6 +5,9 @@ export function isProperFraction(numerator, denominator) { if (numerator > denominator) { return false; } + if (numerator === denominator){ + return false + } if (-numerator < denominator) { return true; } From 32e11b4859402104da210a8ef41733f1451fc369 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 15:30:31 +0100 Subject: [PATCH 062/105] test: add test case for face cards "J", "Q", and "K" in getCardValue function --- .../rewrite-tests-with-jest/3-get-card-value.test.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index a6de5a82a..c5ef86b8a 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -7,6 +7,17 @@ test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); +test(`Should return 10 when given "J" "Q" "K" face card`, () => { + expect(getCardValue("J♠")).toEqual(10); + expect(getCardValue("Q♥")).toEqual(10); + expect(getCardValue("K♣")).toEqual(10); +}); + + + + + + // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) From 84c10da7d64281eff0c6817c3a6c00561927bf46 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 15:42:16 +0100 Subject: [PATCH 063/105] test: add additional test case for Number cards in getCardValue function --- .../rewrite-tests-with-jest/3-get-card-value.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index c5ef86b8a..be39ec494 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -13,6 +13,12 @@ test(`Should return 10 when given "J" "Q" "K" face card`, () => { expect(getCardValue("K♣")).toEqual(10); }); +test(`Should return 2 to 10 when given Number card`, () => { + expect(getCardValue("2♣")).toEqual(2); + expect(getCardValue("5♥")).toEqual(5); + expect(getCardValue("8♠")).toEqual(8); +}) + From b78ad1b1600d17eb9d6c94e1d1baa594b50b8abb Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 15:43:55 +0100 Subject: [PATCH 064/105] fix: correct syntax by closing the Number card test case --- .../rewrite-tests-with-jest/3-get-card-value.test.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index be39ec494..1092a1035 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -17,7 +17,10 @@ test(`Should return 2 to 10 when given Number card`, () => { expect(getCardValue("2♣")).toEqual(2); expect(getCardValue("5♥")).toEqual(5); expect(getCardValue("8♠")).toEqual(8); -}) +}); + + + From 91c33aaefc2c537558ee6219b463301813c7ee24 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 16:14:05 +0100 Subject: [PATCH 065/105] test: add additional test case for invalid cards in getCardValue function --- .../rewrite-tests-with-jest/3-get-card-value.test.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index 1092a1035..3e3f9a0df 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -19,6 +19,15 @@ test(`Should return 2 to 10 when given Number card`, () => { expect(getCardValue("8♠")).toEqual(8); }); +test(`Should throw error when given invalid card`, () => { + expect(() => getCardValue("x♣")).toThrow(); + expect(() => getCardValue("1♥1")).toThrow(); + expect(() => getCardValue("b♣")).toThrow(); + expect(() => getCardValue("k♦j")).toThrow(); +}); + + + From 2f56990149e172b0bdba4edfa925ae1917ec28e4 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 16:27:36 +0100 Subject: [PATCH 066/105] fix: remove redundant invalid card tests in getCardValue function --- .../rewrite-tests-with-jest/3-get-card-value.test.js | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index 3e3f9a0df..80925ba47 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -24,18 +24,12 @@ test(`Should throw error when given invalid card`, () => { expect(() => getCardValue("1♥1")).toThrow(); expect(() => getCardValue("b♣")).toThrow(); expect(() => getCardValue("k♦j")).toThrow(); + expect(() => getCardValue("")).toThrow(); + expect(() => getCardValue("9")).toThrow(); + expect(() => getCardValue("-8♦")).toThrow(); }); - - - - - - - - - // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) From 845c0d9ee4e1660fe76a1ed79b75727ee0c893cb Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 20:47:39 +0100 Subject: [PATCH 067/105] test: add test case to verify countChar returns 0 for non-existent character --- practice-tdd/count.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/practice-tdd/count.test.js b/practice-tdd/count.test.js index cb3aaae59..c3692e841 100644 --- a/practice-tdd/count.test.js +++ b/practice-tdd/count.test.js @@ -22,3 +22,10 @@ test("should count multiple occurrences of a character", () => { // And a character `char` that does not exist within `str`. // When the function is called with these inputs, // Then it should return 0, indicating that no occurrences of `char` were found. + +test("Should return 0 when value does not exist in str", () => { + const str = "zzzzz"; + const char = "a"; + const count = countChar(str, char); + expect(count).toEqual(0); +}) \ No newline at end of file From 10fd986b84bb91dcb64bac39dd0078fc3a53c679 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 20:50:16 +0100 Subject: [PATCH 068/105] fix: implement countChar function to accurately count occurrences of a character --- practice-tdd/count.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/practice-tdd/count.js b/practice-tdd/count.js index 5518c5712..59d7009f8 100644 --- a/practice-tdd/count.js +++ b/practice-tdd/count.js @@ -1,3 +1,10 @@ export function countChar(stringOfCharacters, findCharacter) { - return 5 + let count = 0; + for (const char of stringOfCharacters) { + if (char === findCharacter) { + count++; + } + } + + return count; } From 9693c4beed0fe0cbbd443dccbb1dc26e3b6ae6ce Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 21:28:50 +0100 Subject: [PATCH 069/105] test: add test cases for numbers ending with 2 in getOrdinalNumber function --- practice-tdd/get-ordinal-number.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/practice-tdd/get-ordinal-number.test.js b/practice-tdd/get-ordinal-number.test.js index e23174a18..60d4e2fc8 100644 --- a/practice-tdd/get-ordinal-number.test.js +++ b/practice-tdd/get-ordinal-number.test.js @@ -18,3 +18,10 @@ test("should append 'st' for numbers ending with 1, except those ending with 11" expect(getOrdinalNumber(21)).toEqual("21st"); expect(getOrdinalNumber(131)).toEqual("131st"); }); + +test("Should append 'nd' for numbers ending with 2, except those ending with 12", () => { +expect(getOrdinalNumber(2)).toEqual("2nd"); +expect(getOrdinalNumber(22)).toEqual("22nd"); +expect(getOrdinalNumber(122)).toEqual("122nd") +}) + From 3ad4ad1599fb422ebeadc7dfacc7b59ee1f54da6 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 21:29:05 +0100 Subject: [PATCH 070/105] test: add test cases for numbers ending with 3 in getOrdinalNumber function --- practice-tdd/get-ordinal-number.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/practice-tdd/get-ordinal-number.test.js b/practice-tdd/get-ordinal-number.test.js index 60d4e2fc8..0574336b2 100644 --- a/practice-tdd/get-ordinal-number.test.js +++ b/practice-tdd/get-ordinal-number.test.js @@ -25,3 +25,9 @@ expect(getOrdinalNumber(22)).toEqual("22nd"); expect(getOrdinalNumber(122)).toEqual("122nd") }) +test("Should append 'rd' for numbers ending with 3, except those ending with 13", () => { + expect(getOrdinalNumber(3)).toEqual("3rd"); + expect(getOrdinalNumber(33)).toEqual("33rd"); + expect(getOrdinalNumber(133)).toEqual("133rd"); +}) + From ba47123ebb2213187d4057fd960b3af7acf21f13 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 21:58:50 +0100 Subject: [PATCH 071/105] test: fix formatting in getOrdinalNumber test cases and add missing test for 'th' suffix --- practice-tdd/get-ordinal-number.test.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/practice-tdd/get-ordinal-number.test.js b/practice-tdd/get-ordinal-number.test.js index 0574336b2..765ad8027 100644 --- a/practice-tdd/get-ordinal-number.test.js +++ b/practice-tdd/get-ordinal-number.test.js @@ -22,7 +22,7 @@ test("should append 'st' for numbers ending with 1, except those ending with 11" test("Should append 'nd' for numbers ending with 2, except those ending with 12", () => { expect(getOrdinalNumber(2)).toEqual("2nd"); expect(getOrdinalNumber(22)).toEqual("22nd"); -expect(getOrdinalNumber(122)).toEqual("122nd") +expect(getOrdinalNumber(122)).toEqual("122nd"); }) test("Should append 'rd' for numbers ending with 3, except those ending with 13", () => { @@ -31,3 +31,11 @@ test("Should append 'rd' for numbers ending with 3, except those ending with 13" expect(getOrdinalNumber(133)).toEqual("133rd"); }) +test("Should append 'th' for all numbers including 11, 12, 13, except those ending in 1, 2, 3", () => { + expect(getOrdinalNumber(4)).toEqual("4th"); + expect(getOrdinalNumber(11)).toEqual("11th"); + expect(getOrdinalNumber(12)).toEqual("12th"); + expect(getOrdinalNumber(13)).toEqual("13th"); + expect(getOrdinalNumber(10)).toEqual("10th"); + expect(getOrdinalNumber(111)).toEqual("111th"); +}) From fa8c3b8ea490fe9384a1b951895a250a11bab84b Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 22:14:29 +0100 Subject: [PATCH 072/105] fix: update getOrdinalNumber function to correctly calculate ordinal suffixes --- practice-tdd/get-ordinal-number.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/practice-tdd/get-ordinal-number.js b/practice-tdd/get-ordinal-number.js index 5c6291f5e..a24f197b1 100644 --- a/practice-tdd/get-ordinal-number.js +++ b/practice-tdd/get-ordinal-number.js @@ -1,3 +1,7 @@ export function getOrdinalNumber(num) { - return "1st"; -} + const lastDigit = num % 10; + const lastTwoDigits = num % 100; + + if (lastTwoDigit >= 11 && lastTwoDigits <= 13) { + return `${num}th`; + \ No newline at end of file From c01df9b73a877af2fcfddc100ce84dfb49936503 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 22:14:57 +0100 Subject: [PATCH 073/105] fix: correct logic in getOrdinalNumber function to handle ordinal suffixes for 1, 2, and 3 --- practice-tdd/get-ordinal-number.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/practice-tdd/get-ordinal-number.js b/practice-tdd/get-ordinal-number.js index a24f197b1..89446f785 100644 --- a/practice-tdd/get-ordinal-number.js +++ b/practice-tdd/get-ordinal-number.js @@ -4,4 +4,18 @@ export function getOrdinalNumber(num) { if (lastTwoDigit >= 11 && lastTwoDigits <= 13) { return `${num}th`; + } + if (lastDigit === 1) { + return "1st"; + } + if (lastDigit === 2) { + return "2nd"; + } + if (lastDigit === 3) { + return "3rd"; + } + +} +console.log(getOrdinalNumber(10)) + \ No newline at end of file From b4e124379fb065a7cc276a4521193edf51279efe Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 22:25:37 +0100 Subject: [PATCH 074/105] fix: correct variable name in getOrdinalNumber function to ensure proper logic for ordinal suffixes --- practice-tdd/get-ordinal-number.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/practice-tdd/get-ordinal-number.js b/practice-tdd/get-ordinal-number.js index 89446f785..479934cde 100644 --- a/practice-tdd/get-ordinal-number.js +++ b/practice-tdd/get-ordinal-number.js @@ -2,7 +2,7 @@ export function getOrdinalNumber(num) { const lastDigit = num % 10; const lastTwoDigits = num % 100; - if (lastTwoDigit >= 11 && lastTwoDigits <= 13) { + if (lastTwoDigits >= 11 && lastTwoDigits <= 13) { return `${num}th`; } if (lastDigit === 1) { @@ -14,8 +14,9 @@ export function getOrdinalNumber(num) { if (lastDigit === 3) { return "3rd"; } + return `${num}th`; } -console.log(getOrdinalNumber(10)) +console.log(getOrdinalNumber(100)) \ No newline at end of file From f84d7a0a0a2f3cae9d1e4d6a230916bc089193b8 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 22:26:07 +0100 Subject: [PATCH 075/105] fix: remove unnecessary console.log and ensure proper formatting in getOrdinalNumber function --- practice-tdd/get-ordinal-number.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/practice-tdd/get-ordinal-number.js b/practice-tdd/get-ordinal-number.js index 479934cde..14cbe8be5 100644 --- a/practice-tdd/get-ordinal-number.js +++ b/practice-tdd/get-ordinal-number.js @@ -6,7 +6,7 @@ export function getOrdinalNumber(num) { return `${num}th`; } if (lastDigit === 1) { - return "1st"; + return "1st"; } if (lastDigit === 2) { return "2nd"; @@ -15,8 +15,4 @@ export function getOrdinalNumber(num) { return "3rd"; } return `${num}th`; - } -console.log(getOrdinalNumber(100)) - - \ No newline at end of file From 2d138e0ab426442c2747792834f5fc49d2c76d2e Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 22:37:32 +0100 Subject: [PATCH 076/105] fix: correct return value for ordinal suffix of 1 in getOrdinalNumber function --- practice-tdd/get-ordinal-number.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/practice-tdd/get-ordinal-number.js b/practice-tdd/get-ordinal-number.js index 14cbe8be5..23bf00f74 100644 --- a/practice-tdd/get-ordinal-number.js +++ b/practice-tdd/get-ordinal-number.js @@ -6,7 +6,7 @@ export function getOrdinalNumber(num) { return `${num}th`; } if (lastDigit === 1) { - return "1st"; + return `${num}st`; } if (lastDigit === 2) { return "2nd"; @@ -16,3 +16,4 @@ export function getOrdinalNumber(num) { } return `${num}th`; } +console.log(getOrdinalNumber(21)) From 9dff0ae01dd25739ab115fc4ed1b7a38aea71939 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 22:40:43 +0100 Subject: [PATCH 077/105] fix: update return values in getOrdinalNumber function to use dynamic number formatting --- practice-tdd/get-ordinal-number.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/practice-tdd/get-ordinal-number.js b/practice-tdd/get-ordinal-number.js index 23bf00f74..9a8ed8594 100644 --- a/practice-tdd/get-ordinal-number.js +++ b/practice-tdd/get-ordinal-number.js @@ -9,10 +9,10 @@ export function getOrdinalNumber(num) { return `${num}st`; } if (lastDigit === 2) { - return "2nd"; + return `${num}nd`; } if (lastDigit === 3) { - return "3rd"; + return `${num}rd`; } return `${num}th`; } From 183aacc9a2d5df1a9a2848931b1b1d69a112f3cd Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 23:10:17 +0100 Subject: [PATCH 078/105] test: add test case for repeating the string one time in repeatStr function --- practice-tdd/repeat-str.test.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/practice-tdd/repeat-str.test.js b/practice-tdd/repeat-str.test.js index 8a7036102..cff50a890 100644 --- a/practice-tdd/repeat-str.test.js +++ b/practice-tdd/repeat-str.test.js @@ -16,6 +16,15 @@ test("should repeat the string count times", () => { expect(repeatedStr).toEqual("hellohellohello"); }); +test("should repeat the string one time", () => { + const str = "hello"; + const count = 1; + const repeatedStr = repeatStr(str, count); + expect(repeatedStr).toEqual("hello"); +}); + + + // Case: handle count of 1: // Given a target string `str` and a `count` equal to 1, // When the repeatStr function is called with these inputs, From 42606b642ce50b55c82ce2ae65a3aacb116ecdac Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 23:10:43 +0100 Subject: [PATCH 079/105] test: add test case for returning an empty string when count is 0 in repeatStr function --- practice-tdd/repeat-str.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/practice-tdd/repeat-str.test.js b/practice-tdd/repeat-str.test.js index cff50a890..609c7f7df 100644 --- a/practice-tdd/repeat-str.test.js +++ b/practice-tdd/repeat-str.test.js @@ -23,6 +23,13 @@ test("should repeat the string one time", () => { expect(repeatedStr).toEqual("hello"); }); +test("should return an empty string", () => { + const str = "hello"; + const count = 0; + const repeatedStr = repeatStr(str, count); + expect(repeatedStr).toEqual(""); +}); + // Case: handle count of 1: From 09bf2468fc4fd42ef4f6f024ced6fa298ed4bf05 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 23:10:55 +0100 Subject: [PATCH 080/105] test: add case to handle negative integer input in repeatStr function --- practice-tdd/repeat-str.test.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/practice-tdd/repeat-str.test.js b/practice-tdd/repeat-str.test.js index 609c7f7df..9e46ed649 100644 --- a/practice-tdd/repeat-str.test.js +++ b/practice-tdd/repeat-str.test.js @@ -30,7 +30,11 @@ test("should return an empty string", () => { expect(repeatedStr).toEqual(""); }); - +test("should return invalid when a negative integer is passed", () => { + const str = "hello"; + const count = -2; + expect(() => repeatStr(str, count)).toThrow(); +}); // Case: handle count of 1: // Given a target string `str` and a `count` equal to 1, From 2b76b09a21a8fe11b1982df85c4a74ca9eb08241 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 23:21:35 +0100 Subject: [PATCH 081/105] fix: implement repeatStr function with error handling for negative counts --- practice-tdd/repeat-str.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/practice-tdd/repeat-str.js b/practice-tdd/repeat-str.js index af273f3b0..dcd991ead 100644 --- a/practice-tdd/repeat-str.js +++ b/practice-tdd/repeat-str.js @@ -1,5 +1,7 @@ -export function repeatStr() { - // Your implementation of this function must *not* call String.prototype.repeat (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat). - // The goal is to re-implement that function, not to use it. +export function repeatStr(str, count) { + + if (count < 0) { + throw new Error ("Negative counts are not allowed"); + }; return "hellohellohello"; } From 32c195a85d25b1964009d9b4fad06662df57a9bc Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 23:43:32 +0100 Subject: [PATCH 082/105] fix: implement repeatStr function to return repeated string based on count --- practice-tdd/repeat-str.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/practice-tdd/repeat-str.js b/practice-tdd/repeat-str.js index dcd991ead..fe6e6e8f1 100644 --- a/practice-tdd/repeat-str.js +++ b/practice-tdd/repeat-str.js @@ -1,7 +1,11 @@ export function repeatStr(str, count) { - + if (count < 0) { throw new Error ("Negative counts are not allowed"); }; - return "hellohellohello"; + let result = ""; + for (let i = 0; i < count; i++) { + result += str; + } + return result;; } From 171b264d283e1925093c4a4288e01c51d79b56a3 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 23:45:39 +0100 Subject: [PATCH 083/105] refactor: remove redundant comments from repeatStr test cases --- practice-tdd/repeat-str.test.js | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/practice-tdd/repeat-str.test.js b/practice-tdd/repeat-str.test.js index 9e46ed649..0316dc525 100644 --- a/practice-tdd/repeat-str.test.js +++ b/practice-tdd/repeat-str.test.js @@ -1,13 +1,4 @@ -// Implement a function repeatStr import { repeatStr } from "./repeat-str.js"; -// Given a target string `str` and a positive integer `count`, -// When the repeatStr function is called with these inputs, -// Then it should: - -// Case: handle multiple repetitions: -// Given a target string `str` and a positive integer `count` greater than 1, -// When the repeatStr function is called with these inputs, -// Then it should return a string that contains the original `str` repeated `count` times. test("should repeat the string count times", () => { const str = "hello"; @@ -35,18 +26,3 @@ test("should return invalid when a negative integer is passed", () => { const count = -2; expect(() => repeatStr(str, count)).toThrow(); }); - -// Case: handle count of 1: -// Given a target string `str` and a `count` equal to 1, -// When the repeatStr function is called with these inputs, -// Then it should return the original `str` without repetition. - -// Case: Handle count of 0: -// Given a target string `str` and a `count` equal to 0, -// When the repeatStr function is called with these inputs, -// Then it should return an empty string. - -// Case: Handle negative count: -// Given a target string `str` and a negative integer `count`, -// When the repeatStr function is called with these inputs, -// Then it should throw an error, as negative counts are not valid. From a4b8f77c39311e3271b8a7e6fce97afca86d83c6 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 23:46:17 +0100 Subject: [PATCH 084/105] refactor: remove redundant comments from getOrdinalNumber test file --- practice-tdd/get-ordinal-number.test.js | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/practice-tdd/get-ordinal-number.test.js b/practice-tdd/get-ordinal-number.test.js index 765ad8027..36cf4fcc9 100644 --- a/practice-tdd/get-ordinal-number.test.js +++ b/practice-tdd/get-ordinal-number.test.js @@ -1,18 +1,5 @@ import { getOrdinalNumber } from "./get-ordinal-number.js"; -// In this week's prep, we started implementing getOrdinalNumber. -// Continue testing and implementing getOrdinalNumber for additional cases. -// Write your tests using Jest — remember to run your tests often for continual feedback. - -// To ensure thorough testing, we need broad scenarios that cover all possible cases. -// Listing individual values, however, can quickly lead to an unmanageable number of test cases. -// Instead of writing tests for individual numbers, consider grouping all possible input values -// into meaningful categories. Then, select representative samples from each category to test. -// This approach improves coverage and makes our tests easier to maintain. - -// Case 1: Numbers ending with 1 (but not 11) -// When the number ends with 1, except those ending with 11, -// Then the function should return a string by appending "st" to the number. test("should append 'st' for numbers ending with 1, except those ending with 11", () => { expect(getOrdinalNumber(1)).toEqual("1st"); expect(getOrdinalNumber(21)).toEqual("21st"); From b7bd71073ecd635571884bddf1ddf20313f01e4b Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 23:47:08 +0100 Subject: [PATCH 085/105] refactor: remove redundant comments from countChar test file --- practice-tdd/count.test.js | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/practice-tdd/count.test.js b/practice-tdd/count.test.js index c3692e841..f31c108b6 100644 --- a/practice-tdd/count.test.js +++ b/practice-tdd/count.test.js @@ -1,14 +1,4 @@ -// implement a function countChar that counts the number of times a character occurs in a string import { countChar } from "./count.js"; -// Given a string `str` and a single character `char` to search for, -// When the countChar function is called with these inputs, -// Then it should: - -// Scenario: Multiple Occurrences -// Given the input string `str`, -// And a character `char` that occurs one or more times in `str` (e.g., 'a' in 'aaaaa'), -// When the function is called with these inputs, -// Then it should correctly count occurrences of `char`. test("should count multiple occurrences of a character", () => { const str = "aaaaa"; @@ -17,15 +7,9 @@ test("should count multiple occurrences of a character", () => { expect(count).toEqual(5); }); -// Scenario: No Occurrences -// Given the input string `str`, -// And a character `char` that does not exist within `str`. -// When the function is called with these inputs, -// Then it should return 0, indicating that no occurrences of `char` were found. - test("Should return 0 when value does not exist in str", () => { const str = "zzzzz"; const char = "a"; const count = countChar(str, char); expect(count).toEqual(0); -}) \ No newline at end of file +}); From 5de7ae08faefcfff04a12677818c5bae05ffeb4c Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 23:48:07 +0100 Subject: [PATCH 086/105] refactor: remove TODO comments and suggestions from getCardValue test file --- .../3-get-card-value.test.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index 80925ba47..3698be7a1 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -1,8 +1,5 @@ import { getCardValue } from "../implement/3-get-card-value.js"; -// TODO: Write tests in Jest syntax to cover all possible outcomes. - -// Case 1: Ace (A) test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); @@ -28,14 +25,3 @@ test(`Should throw error when given invalid card`, () => { expect(() => getCardValue("9")).toThrow(); expect(() => getCardValue("-8♦")).toThrow(); }); - - -// Suggestion: Group the remaining test data into these categories: -// Number Cards (2-10) -// Face Cards (J, Q, K) -// Invalid Cards - -// To learn how to test whether a function throws an error as expected in Jest, -// please refer to the Jest documentation: -// https://jestjs.io/docs/expect#tothrowerror - From a2cb8ad0f81e7d96cfa6145ad6eb73601d05a1d7 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 23:48:42 +0100 Subject: [PATCH 087/105] refactor: remove TODO comment and clean up test formatting in isProperFraction test file --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 7b022a4b3..7c5bb1422 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -1,8 +1,5 @@ import { isProperFraction } from "../implement/2-is-proper-fraction.js"; -// TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories. - -// Special case: numerator is zero test(`should return false when denominator is zero`, () => { expect(isProperFraction(1, 0)).toEqual(false); }); @@ -15,7 +12,7 @@ test(`Should return true when denominator is > numerator`, () => { expect(isProperFraction(1, 2)).toEqual(true); }); -test(`Should return true when numerator is zero`, ()=> { +test(`Should return true when numerator is zero`, () => { expect(isProperFraction(0, 4)).toEqual(true); }); From f97fa01f7e7343fe4044b2dd8374e7c26c39a8f2 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 23:49:17 +0100 Subject: [PATCH 088/105] refactor: remove TODO comments and clean up test cases in getAngleType test file --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index 74c0d87fe..ccf7cd423 100644 --- a/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -1,42 +1,32 @@ import { getAngleType } from "../implement/1-get-angle-type.js"; -// TODO: Write tests in Jest syntax to cover all cases/outcomes, -// including boundary and invalid cases. - -// Case 1: Acute angles test(`should return "Acute angle" when (0 < angle < 90)`, () => { - expect(getAngleType(1)).toEqual("Acute angle"); expect(getAngleType(45)).toEqual("Acute angle"); expect(getAngleType(89)).toEqual("Acute angle"); }); test(`Should return "Right angle" when (angle === 90)`, () => { - expect(getAngleType(90)).toEqual("Right angle"); }); test(`Should return "Obtuse Angle" when (angle > 90 and angle < 180)`, () => { - expect(getAngleType(91)).toEqual("Obtuse angle"); expect(getAngleType(120)).toEqual("Obtuse angle"); expect(getAngleType(170)).toEqual("Obtuse angle"); }); test(`Should return "Straight angle" when (angle === 180)`, () => { - expect(getAngleType(180)).toEqual("Straight angle"); }); test(`Should return "Reflex angle" when (angle > 180 and angle < 360)`, () => { - expect(getAngleType(181)).toEqual("Reflex angle"); expect(getAngleType(195)).toEqual("Reflex angle"); expect(getAngleType(290)).toEqual("Reflex angle"); }); test(`Should return "Invalid angle when (angle < 0 and angle > 360)`, () => { - expect(getAngleType(-1)).toEqual("Invalid angle"); expect(getAngleType(361)).toEqual("Invalid angle"); expect(getAngleType(0)).toEqual("Invalid angle"); From 208e10a32ee1b29eb741ff3614b51084eee6edb5 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 23:49:53 +0100 Subject: [PATCH 089/105] refactor: remove TODO comments from getAngleType test file --- .../implement-tests-with-node-test/1-get-angle-type.test.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js index ab665221b..3bda30351 100644 --- a/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js +++ b/implement-and-rewrite-tests/implement-tests-with-node-test/1-get-angle-type.test.js @@ -3,9 +3,6 @@ import test from "node:test"; import { getAngleType } from "../implement/1-get-angle-type.js"; -// TODO: Write tests to cover all cases, including boundary and invalid cases. -// Example: Identify Right Angles - test("Classifies right angles", () => { const right = getAngleType(90); From a13105a2ebd19150217b3cf3602e5867bfc8144f Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Fri, 9 Oct 2026 23:50:25 +0100 Subject: [PATCH 090/105] refactor: remove unnecessary comments from getAngleType function --- .../implement/1-get-angle-type.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/implement-and-rewrite-tests/implement/1-get-angle-type.js b/implement-and-rewrite-tests/implement/1-get-angle-type.js index 9a1b1b16b..267286061 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -1,21 +1,3 @@ -// Implement a function getAngleType -// -// Don't forget to write tests in implement-tests-with-node-test. -// -// When given an angle in degrees, it should return a string indicating the type of angle: -// - "Acute angle" for angles greater than 0° and less than 90° -// - "Right angle" for exactly 90° -// - "Obtuse angle" for angles greater than 90° and less than 180° -// - "Straight angle" for exactly 180° -// - "Reflex angle" for angles greater than 180° and less than 360° -// - "Invalid angle" for angles outside the valid range. - -// Assumption: The parameter is a valid number. (You do not need to handle non-numeric inputs.) - -// Acceptance criteria: -// After you have implemented the function, write tests to cover all the cases, and -// execute the code to ensure all tests pass. - export function getAngleType(angle){ if (angle === 90){ return "Right angle"; From d8e897431cba3277ea24ed0fba97f251fc5fe3e8 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 10 Oct 2026 08:36:04 +0100 Subject: [PATCH 091/105] refactor: add test case for password containing at least one uppercase letter --- sprint-3-stretch-exercises/password-validator.test.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sprint-3-stretch-exercises/password-validator.test.js b/sprint-3-stretch-exercises/password-validator.test.js index 2a58a0fb6..fb811e905 100644 --- a/sprint-3-stretch-exercises/password-validator.test.js +++ b/sprint-3-stretch-exercises/password-validator.test.js @@ -23,4 +23,12 @@ test("password has at least 5 characters", () => { // Assert expect(result).toEqual(true); } -); \ No newline at end of file +); + +test("Password has at least one upperCase letter", () => { + + const password = "A1234"; + const result = isValidPassword(password); + expect(result).toEqual(true); +}); + From 8b50775c6340fc494968e94180a2354aeb97efaf Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 10 Oct 2026 08:36:21 +0100 Subject: [PATCH 092/105] refactor: add test case for password containing at least one lowercase letter --- sprint-3-stretch-exercises/password-validator.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sprint-3-stretch-exercises/password-validator.test.js b/sprint-3-stretch-exercises/password-validator.test.js index fb811e905..7ad9defac 100644 --- a/sprint-3-stretch-exercises/password-validator.test.js +++ b/sprint-3-stretch-exercises/password-validator.test.js @@ -32,3 +32,11 @@ test("Password has at least one upperCase letter", () => { expect(result).toEqual(true); }); +test("Password has at least one lowerCase letter", () => { + + const password = "Ab123"; + const result = isValidPassword(password); + expect(result).toEqual(true) +}); + + From 34edfce212a9953b9d2bc2d963a7156797d96371 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 10 Oct 2026 08:36:35 +0100 Subject: [PATCH 093/105] refactor: add test case for password containing at least one number --- sprint-3-stretch-exercises/password-validator.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sprint-3-stretch-exercises/password-validator.test.js b/sprint-3-stretch-exercises/password-validator.test.js index 7ad9defac..1b5b7c543 100644 --- a/sprint-3-stretch-exercises/password-validator.test.js +++ b/sprint-3-stretch-exercises/password-validator.test.js @@ -39,4 +39,11 @@ test("Password has at least one lowerCase letter", () => { expect(result).toEqual(true) }); +test("Password has at least one number 0 - 9", () => { + + const password = "Ab123"; + const result = isValidPassword(password); + expect(result).toEqual(true); +}); + From a0fc1e8efab80d127bee539909d18e926b68f318 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 10 Oct 2026 08:36:51 +0100 Subject: [PATCH 094/105] refactor: add test case for password containing at least one special non-alphanumeric symbol --- sprint-3-stretch-exercises/password-validator.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sprint-3-stretch-exercises/password-validator.test.js b/sprint-3-stretch-exercises/password-validator.test.js index 1b5b7c543..2791989d6 100644 --- a/sprint-3-stretch-exercises/password-validator.test.js +++ b/sprint-3-stretch-exercises/password-validator.test.js @@ -46,4 +46,9 @@ test("Password has at least one number 0 - 9", () => { expect(result).toEqual(true); }); +test("Password has at least one special non-alphanumeric symbols", () => { + const password = "Ab12#"; + const result = isValidPassword(password); + expect(result).toEqual(true); +}); From 4b5f2f70b057c1beccee00fac410484005063902 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 10 Oct 2026 08:37:07 +0100 Subject: [PATCH 095/105] refactor: clean up test case formatting for password validation --- .../password-validator.test.js | 43 ++++++++----------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/sprint-3-stretch-exercises/password-validator.test.js b/sprint-3-stretch-exercises/password-validator.test.js index 2791989d6..01d0bea63 100644 --- a/sprint-3-stretch-exercises/password-validator.test.js +++ b/sprint-3-stretch-exercises/password-validator.test.js @@ -16,39 +16,34 @@ You must breakdown this problem in order to solve it. Find one test case first a */ import { isValidPassword } from "./password-validator.js"; test("password has at least 5 characters", () => { - // Arrange - const password = "12345"; - // Act - const result = isValidPassword(password); - // Assert - expect(result).toEqual(true); -} -); + // Arrange + const password = "12345"; + // Act + const result = isValidPassword(password); + // Assert + expect(result).toEqual(true); +}); test("Password has at least one upperCase letter", () => { - - const password = "A1234"; - const result = isValidPassword(password); - expect(result).toEqual(true); + const password = "A1234"; + const result = isValidPassword(password); + expect(result).toEqual(true); }); test("Password has at least one lowerCase letter", () => { - - const password = "Ab123"; - const result = isValidPassword(password); - expect(result).toEqual(true) + const password = "Ab123"; + const result = isValidPassword(password); + expect(result).toEqual(true); }); test("Password has at least one number 0 - 9", () => { - - const password = "Ab123"; - const result = isValidPassword(password); - expect(result).toEqual(true); + const password = "Ab123"; + const result = isValidPassword(password); + expect(result).toEqual(true); }); test("Password has at least one special non-alphanumeric symbols", () => { - - const password = "Ab12#"; - const result = isValidPassword(password); - expect(result).toEqual(true); + const password = "Ab12#"; + const result = isValidPassword(password); + expect(result).toEqual(true); }); From 88908c79a4887db850447539eb4e7d0f2f2c8731 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 10 Oct 2026 08:46:45 +0100 Subject: [PATCH 096/105] refactor: add test case to ensure password is not a previous password --- sprint-3-stretch-exercises/password-validator.test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sprint-3-stretch-exercises/password-validator.test.js b/sprint-3-stretch-exercises/password-validator.test.js index 01d0bea63..83b951cb0 100644 --- a/sprint-3-stretch-exercises/password-validator.test.js +++ b/sprint-3-stretch-exercises/password-validator.test.js @@ -47,3 +47,11 @@ test("Password has at least one special non-alphanumeric symbols", () => { const result = isValidPassword(password); expect(result).toEqual(true); }); + +test("Password must not be a previous password", () => { + const password = "Ab12#"; + const passwords = ["Ab12#"]; + const result = isValidPassword(password, passwords); + expect(result).toEqual(false); +}); + From 36105dfa70e121ff4d592822ecdc1c7a3029e793 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 10 Oct 2026 08:46:51 +0100 Subject: [PATCH 097/105] refactor: update isValidPassword function to accept an additional parameter for password history --- sprint-3-stretch-exercises/password-validator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sprint-3-stretch-exercises/password-validator.js b/sprint-3-stretch-exercises/password-validator.js index ac70324a5..e8cacd794 100644 --- a/sprint-3-stretch-exercises/password-validator.js +++ b/sprint-3-stretch-exercises/password-validator.js @@ -1,3 +1,3 @@ -export function isValidPassword(password) { +export function isValidPassword(password, password = []) { return password.length >= 5; } From 53379400a0372c84db28a006833ee8bbce134773 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 10 Oct 2026 08:49:22 +0100 Subject: [PATCH 098/105] refactor: fix isValidPassword function to correctly check for previous passwords --- sprint-3-stretch-exercises/password-validator.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sprint-3-stretch-exercises/password-validator.js b/sprint-3-stretch-exercises/password-validator.js index e8cacd794..f8a539445 100644 --- a/sprint-3-stretch-exercises/password-validator.js +++ b/sprint-3-stretch-exercises/password-validator.js @@ -1,3 +1,6 @@ export function isValidPassword(password, password = []) { + if (password.includes(password)) { + return false + } return password.length >= 5; } From 8849988004b0de48a22538df57ab3174426a5a02 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 10 Oct 2026 08:54:58 +0100 Subject: [PATCH 099/105] refactor: fix parameter name in isValidPassword function for clarity --- sprint-3-stretch-exercises/password-validator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sprint-3-stretch-exercises/password-validator.js b/sprint-3-stretch-exercises/password-validator.js index f8a539445..3a85aae03 100644 --- a/sprint-3-stretch-exercises/password-validator.js +++ b/sprint-3-stretch-exercises/password-validator.js @@ -1,4 +1,4 @@ -export function isValidPassword(password, password = []) { +export function isValidPassword(password, passwords = []) { if (password.includes(password)) { return false } From 570fb97a718f5faa6a2387425b53dd292cd6fce9 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 10 Oct 2026 08:56:09 +0100 Subject: [PATCH 100/105] refactor: fix condition in isValidPassword function to check against password history --- sprint-3-stretch-exercises/password-validator.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sprint-3-stretch-exercises/password-validator.js b/sprint-3-stretch-exercises/password-validator.js index 3a85aae03..c627da589 100644 --- a/sprint-3-stretch-exercises/password-validator.js +++ b/sprint-3-stretch-exercises/password-validator.js @@ -1,6 +1,7 @@ export function isValidPassword(password, passwords = []) { - if (password.includes(password)) { + if (passwords.includes(password)) { return false } + return password.length >= 5; } From 3cabf33ba54786cb0fe23e0307dffe00e45c0e8d Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 10 Oct 2026 08:57:54 +0100 Subject: [PATCH 101/105] refactor: improve readability by adjusting whitespace in isValidPassword function --- sprint-3-stretch-exercises/password-validator.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sprint-3-stretch-exercises/password-validator.js b/sprint-3-stretch-exercises/password-validator.js index c627da589..d2eb745fe 100644 --- a/sprint-3-stretch-exercises/password-validator.js +++ b/sprint-3-stretch-exercises/password-validator.js @@ -2,6 +2,8 @@ export function isValidPassword(password, passwords = []) { if (passwords.includes(password)) { return false } - + if (!/[a-z]/.test(password)) { + return false + } return password.length >= 5; } From 7fec32ac390e4274e695825e0a928f4c0c598afa Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 10 Oct 2026 09:58:39 +0100 Subject: [PATCH 102/105] refactor: fix formatting issues in isValidPassword function for consistency --- .../password-validator.js | 10 +++++-- .../password-validator.test.js | 28 ++++--------------- 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/sprint-3-stretch-exercises/password-validator.js b/sprint-3-stretch-exercises/password-validator.js index d2eb745fe..58512de62 100644 --- a/sprint-3-stretch-exercises/password-validator.js +++ b/sprint-3-stretch-exercises/password-validator.js @@ -1,9 +1,15 @@ export function isValidPassword(password, passwords = []) { if (passwords.includes(password)) { - return false + return false; } if (!/[a-z]/.test(password)) { - return false + return false; + } + if (!/[0-9]/.test(password)) { + return false; + } + if (!/[!#$%.*&]/.test(password)) { + return false; } return password.length >= 5; } diff --git a/sprint-3-stretch-exercises/password-validator.test.js b/sprint-3-stretch-exercises/password-validator.test.js index 83b951cb0..7836f9b55 100644 --- a/sprint-3-stretch-exercises/password-validator.test.js +++ b/sprint-3-stretch-exercises/password-validator.test.js @@ -1,43 +1,25 @@ -/* -Password Validation - -Write a program that should check if a password is valid -and returns a boolean - -To be valid, a password must: -- Have at least 5 characters. -- Have at least one English uppercase letter (A-Z) -- Have at least one English lowercase letter (a-z) -- Have at least one number (0-9) -- Have at least one of the following non-alphanumeric symbols: ("!", "#", "$", "%", ".", "*", "&") -- Must not be any previous password in the passwords array. - -You must breakdown this problem in order to solve it. Find one test case first and get that working -*/ import { isValidPassword } from "./password-validator.js"; test("password has at least 5 characters", () => { - // Arrange - const password = "12345"; - // Act + + const password = "Ab12#"; const result = isValidPassword(password); - // Assert expect(result).toEqual(true); }); test("Password has at least one upperCase letter", () => { - const password = "A1234"; + const password = "Ab12#"; const result = isValidPassword(password); expect(result).toEqual(true); }); test("Password has at least one lowerCase letter", () => { - const password = "Ab123"; + const password = "Ab12#"; const result = isValidPassword(password); expect(result).toEqual(true); }); test("Password has at least one number 0 - 9", () => { - const password = "Ab123"; + const password = "Ab12#"; const result = isValidPassword(password); expect(result).toEqual(true); }); From 79e90d032bfb2f48ffd318534d53674d73b9bbd8 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 10 Oct 2026 12:06:17 +0100 Subject: [PATCH 103/105] remove password validator stretch exercise --- .../password-validator.js | 15 ------- .../password-validator.test.js | 39 ------------------- 2 files changed, 54 deletions(-) delete mode 100644 sprint-3-stretch-exercises/password-validator.js delete mode 100644 sprint-3-stretch-exercises/password-validator.test.js diff --git a/sprint-3-stretch-exercises/password-validator.js b/sprint-3-stretch-exercises/password-validator.js deleted file mode 100644 index 58512de62..000000000 --- a/sprint-3-stretch-exercises/password-validator.js +++ /dev/null @@ -1,15 +0,0 @@ -export function isValidPassword(password, passwords = []) { - if (passwords.includes(password)) { - return false; - } - if (!/[a-z]/.test(password)) { - return false; - } - if (!/[0-9]/.test(password)) { - return false; - } - if (!/[!#$%.*&]/.test(password)) { - return false; - } - return password.length >= 5; -} diff --git a/sprint-3-stretch-exercises/password-validator.test.js b/sprint-3-stretch-exercises/password-validator.test.js deleted file mode 100644 index 7836f9b55..000000000 --- a/sprint-3-stretch-exercises/password-validator.test.js +++ /dev/null @@ -1,39 +0,0 @@ -import { isValidPassword } from "./password-validator.js"; -test("password has at least 5 characters", () => { - - const password = "Ab12#"; - const result = isValidPassword(password); - expect(result).toEqual(true); -}); - -test("Password has at least one upperCase letter", () => { - const password = "Ab12#"; - const result = isValidPassword(password); - expect(result).toEqual(true); -}); - -test("Password has at least one lowerCase letter", () => { - const password = "Ab12#"; - const result = isValidPassword(password); - expect(result).toEqual(true); -}); - -test("Password has at least one number 0 - 9", () => { - const password = "Ab12#"; - const result = isValidPassword(password); - expect(result).toEqual(true); -}); - -test("Password has at least one special non-alphanumeric symbols", () => { - const password = "Ab12#"; - const result = isValidPassword(password); - expect(result).toEqual(true); -}); - -test("Password must not be a previous password", () => { - const password = "Ab12#"; - const passwords = ["Ab12#"]; - const result = isValidPassword(password, passwords); - expect(result).toEqual(false); -}); - From 0bfe6960bbc57882f8236b9e9eb192150563a99d Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 10 Oct 2026 12:44:21 +0100 Subject: [PATCH 104/105] reset practice-tdd to main starter files --- practice-tdd/count.js | 9 +----- practice-tdd/count.test.js | 21 ++++++++++---- practice-tdd/get-ordinal-number.js | 18 +----------- practice-tdd/get-ordinal-number.test.js | 34 +++++++++------------- practice-tdd/repeat-str.js | 14 +++------ practice-tdd/repeat-str.test.js | 38 ++++++++++++++----------- 6 files changed, 55 insertions(+), 79 deletions(-) diff --git a/practice-tdd/count.js b/practice-tdd/count.js index 59d7009f8..5518c5712 100644 --- a/practice-tdd/count.js +++ b/practice-tdd/count.js @@ -1,10 +1,3 @@ export function countChar(stringOfCharacters, findCharacter) { - let count = 0; - for (const char of stringOfCharacters) { - if (char === findCharacter) { - count++; - } - } - - return count; + return 5 } diff --git a/practice-tdd/count.test.js b/practice-tdd/count.test.js index f31c108b6..cb3aaae59 100644 --- a/practice-tdd/count.test.js +++ b/practice-tdd/count.test.js @@ -1,4 +1,14 @@ +// implement a function countChar that counts the number of times a character occurs in a string import { countChar } from "./count.js"; +// Given a string `str` and a single character `char` to search for, +// When the countChar function is called with these inputs, +// Then it should: + +// Scenario: Multiple Occurrences +// Given the input string `str`, +// And a character `char` that occurs one or more times in `str` (e.g., 'a' in 'aaaaa'), +// When the function is called with these inputs, +// Then it should correctly count occurrences of `char`. test("should count multiple occurrences of a character", () => { const str = "aaaaa"; @@ -7,9 +17,8 @@ test("should count multiple occurrences of a character", () => { expect(count).toEqual(5); }); -test("Should return 0 when value does not exist in str", () => { - const str = "zzzzz"; - const char = "a"; - const count = countChar(str, char); - expect(count).toEqual(0); -}); +// Scenario: No Occurrences +// Given the input string `str`, +// And a character `char` that does not exist within `str`. +// When the function is called with these inputs, +// Then it should return 0, indicating that no occurrences of `char` were found. diff --git a/practice-tdd/get-ordinal-number.js b/practice-tdd/get-ordinal-number.js index 9a8ed8594..5c6291f5e 100644 --- a/practice-tdd/get-ordinal-number.js +++ b/practice-tdd/get-ordinal-number.js @@ -1,19 +1,3 @@ export function getOrdinalNumber(num) { - const lastDigit = num % 10; - const lastTwoDigits = num % 100; - - if (lastTwoDigits >= 11 && lastTwoDigits <= 13) { - return `${num}th`; - } - if (lastDigit === 1) { - return `${num}st`; - } - if (lastDigit === 2) { - return `${num}nd`; - } - if (lastDigit === 3) { - return `${num}rd`; - } - return `${num}th`; + return "1st"; } -console.log(getOrdinalNumber(21)) diff --git a/practice-tdd/get-ordinal-number.test.js b/practice-tdd/get-ordinal-number.test.js index 36cf4fcc9..e23174a18 100644 --- a/practice-tdd/get-ordinal-number.test.js +++ b/practice-tdd/get-ordinal-number.test.js @@ -1,28 +1,20 @@ import { getOrdinalNumber } from "./get-ordinal-number.js"; +// In this week's prep, we started implementing getOrdinalNumber. +// Continue testing and implementing getOrdinalNumber for additional cases. +// Write your tests using Jest — remember to run your tests often for continual feedback. + +// To ensure thorough testing, we need broad scenarios that cover all possible cases. +// Listing individual values, however, can quickly lead to an unmanageable number of test cases. +// Instead of writing tests for individual numbers, consider grouping all possible input values +// into meaningful categories. Then, select representative samples from each category to test. +// This approach improves coverage and makes our tests easier to maintain. + +// Case 1: Numbers ending with 1 (but not 11) +// When the number ends with 1, except those ending with 11, +// Then the function should return a string by appending "st" to the number. test("should append 'st' for numbers ending with 1, except those ending with 11", () => { expect(getOrdinalNumber(1)).toEqual("1st"); expect(getOrdinalNumber(21)).toEqual("21st"); expect(getOrdinalNumber(131)).toEqual("131st"); }); - -test("Should append 'nd' for numbers ending with 2, except those ending with 12", () => { -expect(getOrdinalNumber(2)).toEqual("2nd"); -expect(getOrdinalNumber(22)).toEqual("22nd"); -expect(getOrdinalNumber(122)).toEqual("122nd"); -}) - -test("Should append 'rd' for numbers ending with 3, except those ending with 13", () => { - expect(getOrdinalNumber(3)).toEqual("3rd"); - expect(getOrdinalNumber(33)).toEqual("33rd"); - expect(getOrdinalNumber(133)).toEqual("133rd"); -}) - -test("Should append 'th' for all numbers including 11, 12, 13, except those ending in 1, 2, 3", () => { - expect(getOrdinalNumber(4)).toEqual("4th"); - expect(getOrdinalNumber(11)).toEqual("11th"); - expect(getOrdinalNumber(12)).toEqual("12th"); - expect(getOrdinalNumber(13)).toEqual("13th"); - expect(getOrdinalNumber(10)).toEqual("10th"); - expect(getOrdinalNumber(111)).toEqual("111th"); -}) diff --git a/practice-tdd/repeat-str.js b/practice-tdd/repeat-str.js index fe6e6e8f1..af273f3b0 100644 --- a/practice-tdd/repeat-str.js +++ b/practice-tdd/repeat-str.js @@ -1,11 +1,5 @@ -export function repeatStr(str, count) { - - if (count < 0) { - throw new Error ("Negative counts are not allowed"); - }; - let result = ""; - for (let i = 0; i < count; i++) { - result += str; - } - return result;; +export function repeatStr() { + // Your implementation of this function must *not* call String.prototype.repeat (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat). + // The goal is to re-implement that function, not to use it. + return "hellohellohello"; } diff --git a/practice-tdd/repeat-str.test.js b/practice-tdd/repeat-str.test.js index 0316dc525..8a7036102 100644 --- a/practice-tdd/repeat-str.test.js +++ b/practice-tdd/repeat-str.test.js @@ -1,4 +1,13 @@ +// Implement a function repeatStr import { repeatStr } from "./repeat-str.js"; +// Given a target string `str` and a positive integer `count`, +// When the repeatStr function is called with these inputs, +// Then it should: + +// Case: handle multiple repetitions: +// Given a target string `str` and a positive integer `count` greater than 1, +// When the repeatStr function is called with these inputs, +// Then it should return a string that contains the original `str` repeated `count` times. test("should repeat the string count times", () => { const str = "hello"; @@ -7,22 +16,17 @@ test("should repeat the string count times", () => { expect(repeatedStr).toEqual("hellohellohello"); }); -test("should repeat the string one time", () => { - const str = "hello"; - const count = 1; - const repeatedStr = repeatStr(str, count); - expect(repeatedStr).toEqual("hello"); -}); +// Case: handle count of 1: +// Given a target string `str` and a `count` equal to 1, +// When the repeatStr function is called with these inputs, +// Then it should return the original `str` without repetition. -test("should return an empty string", () => { - const str = "hello"; - const count = 0; - const repeatedStr = repeatStr(str, count); - expect(repeatedStr).toEqual(""); -}); +// Case: Handle count of 0: +// Given a target string `str` and a `count` equal to 0, +// When the repeatStr function is called with these inputs, +// Then it should return an empty string. -test("should return invalid when a negative integer is passed", () => { - const str = "hello"; - const count = -2; - expect(() => repeatStr(str, count)).toThrow(); -}); +// Case: Handle negative count: +// Given a target string `str` and a negative integer `count`, +// When the repeatStr function is called with these inputs, +// Then it should throw an error, as negative counts are not valid. From 1732a61498b332e764d9921ae0724c06a95eb101 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Sat, 10 Oct 2026 12:55:50 +0100 Subject: [PATCH 105/105] restore sprint-3-stretch-exercises from main --- .../password-validator.js | 3 +++ .../password-validator.test.js | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 sprint-3-stretch-exercises/password-validator.js create mode 100644 sprint-3-stretch-exercises/password-validator.test.js diff --git a/sprint-3-stretch-exercises/password-validator.js b/sprint-3-stretch-exercises/password-validator.js new file mode 100644 index 000000000..ac70324a5 --- /dev/null +++ b/sprint-3-stretch-exercises/password-validator.js @@ -0,0 +1,3 @@ +export function isValidPassword(password) { + return password.length >= 5; +} diff --git a/sprint-3-stretch-exercises/password-validator.test.js b/sprint-3-stretch-exercises/password-validator.test.js new file mode 100644 index 000000000..2a58a0fb6 --- /dev/null +++ b/sprint-3-stretch-exercises/password-validator.test.js @@ -0,0 +1,26 @@ +/* +Password Validation + +Write a program that should check if a password is valid +and returns a boolean + +To be valid, a password must: +- Have at least 5 characters. +- Have at least one English uppercase letter (A-Z) +- Have at least one English lowercase letter (a-z) +- Have at least one number (0-9) +- Have at least one of the following non-alphanumeric symbols: ("!", "#", "$", "%", ".", "*", "&") +- Must not be any previous password in the passwords array. + +You must breakdown this problem in order to solve it. Find one test case first and get that working +*/ +import { isValidPassword } from "./password-validator.js"; +test("password has at least 5 characters", () => { + // Arrange + const password = "12345"; + // Act + const result = isValidPassword(password); + // Assert + expect(result).toEqual(true); +} +); \ No newline at end of file