From a858778a0962485c21f0f4508762fd9d7a83625a Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sat, 17 Oct 2026 20:13:28 +0100 Subject: [PATCH 01/12] Add tests for angle classification and invalid angle handling --- .../1-get-angle-type.test.js | 25 +++++++++++++++++++ 1 file changed, 25 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 cf50f6cade..5620111c33 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,28 @@ 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"); +}); + +test("Classifies obtuse angles", () => { + const obtuse = getAngleType(120); + assert.equal(obtuse, "Obtuse angle"); +}); + +test("Classifies straight angles", () => { + const straight = getAngleType(180); + assert.equal(straight, "Straight angle"); +}); + +test("Classifies reflex angles", () => { + const reflex = getAngleType(270); + assert.equal(reflex, "Reflex angle"); +}); + +test("Handles invalid angles (negative)", () => { + const invalidNegative = getAngleType(-30); + assert.equal(invalidNegative, "Invalid angle"); +}); \ No newline at end of file From bc6d7cd8490913e99fb37200e3572fd5073e0baf Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sun, 18 Oct 2026 14:42:55 +0100 Subject: [PATCH 02/12] Implement getAngleType function to classify angles --- .../implement/1-get-angle-type.js | 27 +++++++++++++++++-- 1 file changed, 25 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 8a6fba0504..a6e37896d7 100644 --- a/implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -1,4 +1,5 @@ // Implement a function getAngleType + // // Don't forget to write tests in implement-tests-with-node-test. // @@ -16,6 +17,28 @@ // 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 -} + function getAngleType(angle) { + if (angle === 90) { + return "Right angle"; + } + else if (angle > 0 && angle < 90) { + return "Acute angle"; + } + else if (angle > 90 && angle < 180) { + return "Obtuse angle"; + } + else if (angle === 180) { + return "Straight angle"; + } + else if (angle > 180 && angle < 360) { + return "Reflex angle"; + } + else { + return "Invalid angle"; + } +} + + +export { getAngleType }; \ No newline at end of file From a1953c551aab3bb714d0dd7650f174f28e530434 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sun, 18 Oct 2026 14:52:28 +0100 Subject: [PATCH 03/12] Add additional test cases for isProperFraction function --- .../2-is-proper-fraction.test.js | 30 +++++++++++++++++++ .../implement/2-is-proper-fraction.js | 5 ++-- 2 files changed, 33 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 a290846058..80dd4b7d9c 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 @@ -10,3 +10,33 @@ test("Basic proper fraction", () => { // Example: 1/2 is a proper fraction assert.equal(isProperFraction(1, 2), true); }); + +test("Numerator is zero", () => { + // Example: 0/5 is a proper fraction + assert.equal(isProperFraction(0, 5), true); +}); + +test("Numerator is equal to denominator", () => { + // Example: 3/3 is not a proper fraction + assert.equal(isProperFraction(3, 3), false); +}); + +test("Numerator is greater than denominator", () => { + // Example: 5/3 is not a proper fraction + assert.equal(isProperFraction(5, 3), false); +}); + +test("Negative numerator and positive denominator", () => { + // Example: -1/2 is a proper fraction + assert.equal(isProperFraction(-1, 2), true); +}); + +test("Positive numerator and negative denominator", () => { + // Example: 1/-2 is a proper fraction + assert.equal(isProperFraction(1, -2), true); +}); + +test("Negative numerator and negative denominator", () => { + // Example: -1/-2 is a proper fraction + assert.equal(isProperFraction(-1, -2), true); +}); \ No newline at end of file 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 f983800f00..fb80e11ffc 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -13,6 +13,7 @@ // 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) { + // TODO: Implement this function -} + + \ No newline at end of file From d35b1f4f940f077d85ade8103680a4d3e7fc107e Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sun, 18 Oct 2026 14:54:10 +0100 Subject: [PATCH 04/12] Implement isProperFraction function --- .../implement/2-is-proper-fraction.js | 7 ++++++- 1 file changed, 6 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 fb80e11ffc..0d323a9ef4 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -16,4 +16,9 @@ // TODO: Implement this function - \ No newline at end of file + function isProperFraction(numerator, denominator) { + + + } + + From 93c22c44dd830e2d21dd5308cad3ead7db4d89d1 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sun, 18 Oct 2026 14:54:36 +0100 Subject: [PATCH 05/12] Export isProperFraction function for external use --- implement-and-rewrite-tests/implement/2-is-proper-fraction.js | 2 ++ 1 file changed, 2 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 0d323a9ef4..1c503574dd 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -21,4 +21,6 @@ } + export { isProperFraction }; + From a86c8c6655df5c343739924d8b8cca00e1529ae0 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sun, 18 Oct 2026 14:55:02 +0100 Subject: [PATCH 06/12] Implement isProperFraction function to evaluate proper fractions --- implement-and-rewrite-tests/implement/2-is-proper-fraction.js | 2 ++ 1 file changed, 2 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 1c503574dd..0ba3f1d06a 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -17,6 +17,8 @@ // TODO: Implement this function function isProperFraction(numerator, denominator) { + + return Math.abs(numerator) < Math.abs(denominator); } From efc3a80af38d99a81ac9ce25ee2f69bb01c83d36 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sun, 18 Oct 2026 15:02:38 +0100 Subject: [PATCH 07/12] Refactor isProperFraction function by removing unnecessary whitespace --- implement-and-rewrite-tests/implement/2-is-proper-fraction.js | 2 -- 1 file changed, 2 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 0ba3f1d06a..8bb8e3e05d 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -17,9 +17,7 @@ // TODO: Implement this function function isProperFraction(numerator, denominator) { - return Math.abs(numerator) < Math.abs(denominator); - } From 8ff7fc50eaafba46358eee80dc48efb8b251ec19 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sun, 18 Oct 2026 15:16:41 +0100 Subject: [PATCH 08/12] Add tests for valid and invalid card values in getCardValue function --- .../3-get-card-value.test.js | 53 +++++++++++++++++++ .../implement/2-is-proper-fraction.js | 1 + 2 files changed, 54 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 f5092d9b10..c82f57262c 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,4 +13,57 @@ test("Arbitrary non-card string", () => { assert.throws(() => getCardValue("invalid"), /Expected a number followed by a suit, but got "invalid"/, "Expected clear error"); }); +test("Valid face card", () => { + assert.equal(getCardValue("J♣"), 10); +}); + +test("Valid ace card", () => { + assert.equal(getCardValue("A♦"), 11); +}); + +test("Valid ten card", () => { + assert.equal(getCardValue("10♥"), 10); +}); + +test("Invalid card with missing suit", () => { + assert.throws(() => getCardValue("5"), "Expected clear error"); +}); + +test("Invalid card with missing rank", () => { + assert.throws(() => getCardValue("♠"), "Expected clear error"); +}); + +test("Invalid card with extra characters", () => { + assert.throws(() => getCardValue("10♠extra"), "Expected clear error"); +}); + +test("Invalid card with invalid rank", () => { + assert.throws(() => getCardValue("11♠"), "Expected clear error"); +}); + +test("Invalid card with invalid suit", () => { + assert.throws(() => getCardValue("10X"), "Expected clear error"); +}); + // TODO: What other invalid card cases can you think of? + +test("Invalid card with missing suit", () => { + assert.throws(() => getCardValue("5"), "Expected clear error"); +}); + +test("Invalid card with missing rank", () => { + assert.throws(() => getCardValue("♠"), "Expected clear error"); +}); + +test("Invalid card with extra characters", () => { + assert.throws(() => getCardValue("10♠extra"), "Expected clear error"); +}); + +test("Invalid card with invalid rank", () => { + assert.throws(() => getCardValue("11♠"), "Expected clear error"); +}); + +test("Invalid card with invalid suit", () => { + assert.throws(() => getCardValue("10X"), "Expected clear error"); +}); + 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 8bb8e3e05d..2ac36b6b5f 100644 --- a/implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -16,6 +16,7 @@ // TODO: Implement this function + function isProperFraction(numerator, denominator) { return Math.abs(numerator) < Math.abs(denominator); From d9ea1d233e359349ed84f2f947e2736ac5844c9e Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sun, 18 Oct 2026 15:30:43 +0100 Subject: [PATCH 09/12] Implement getCardValue function to return the numerical value of playing cards --- .../implement/3-get-card-value.js | 17 ++++++++++++++++- 1 file changed, 16 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 9614ab1ee9..6054cdacea 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -23,6 +23,21 @@ // 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) { + // TODO: Implement this function +function getCardValue(card) { + const validRanks = ["A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"]; + const validSuits = ["♠", "♥", "♦", "♣"]; + + // Check if the card string is valid + const rank = card.slice(0, -1); + const suit = card.slice(-1); + + if (!validRanks.includes(rank) || !validSuits.includes(suit)) { + throw new Error(`Expected a number followed by a suit, but got "${card}"`); + } + + } + +export { getCardValue }; From a4c1f6f9a0f258766b49bd6f4534be0f51164079 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Sun, 18 Oct 2026 15:33:44 +0100 Subject: [PATCH 10/12] Implement logic to determine the numerical value of playing cards in getCardValue function --- .../implement/3-get-card-value.js | 9 +++++++++ 1 file changed, 9 insertions(+) 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 6054cdacea..bede1b1c58 100644 --- a/implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/implement-and-rewrite-tests/implement/3-get-card-value.js @@ -37,6 +37,15 @@ function getCardValue(card) { throw new Error(`Expected a number followed by a suit, but got "${card}"`); } + // Determine the value of the card + if (rank === "A") { + return 11; + } else if (["J", "Q", "K"].includes(rank)) { + return 10; + } else { + return parseInt(rank, 10); + } + } From d67939fe9ad410e3ba92f576a78b3d0dbff297b9 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Wed, 11 Nov 2026 07:27:13 +0000 Subject: [PATCH 11/12] Add tests for angle classification boundaries and invalid angles --- .../1-get-angle-type.test.js | 17 ++++++++++++++++- 1 file changed, 16 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 5620111c33..062592fd24 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 @@ -34,4 +34,19 @@ test("Classifies reflex angles", () => { test("Handles invalid angles (negative)", () => { const invalidNegative = getAngleType(-30); assert.equal(invalidNegative, "Invalid angle"); -}); \ No newline at end of file +}); + +test("classifies acute angle boundary ", () => { + const acuteBoundary = getAngleType(1); + assert.equal(acuteBoundary, "Acute angle"); +}); + +test("classifies obtuse angle boundary ", () => { + const obtuseBoundary = getAngleType(180); + assert.equal(obtuseBoundary, "Straight angle"); +}); + +test("Handles invalid angles (greater than 360)", () => { + const invalidGreaterThan360 = getAngleType(400); + assert.equal(invalidGreaterThan360, "Invalid angle"); +}); From 618e77e7ac64ad362bbf83836d469542cf1dfbf2 Mon Sep 17 00:00:00 2001 From: Monsur Abdulrahman Date: Wed, 11 Nov 2026 07:29:56 +0000 Subject: [PATCH 12/12] Add tests for reflex, right, and straight angle boundaries in getAngleType function --- .../1-get-angle-type.test.js | 15 +++++++++++++++ 1 file changed, 15 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 062592fd24..e60838eda8 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 @@ -46,6 +46,21 @@ test("classifies obtuse angle boundary ", () => { assert.equal(obtuseBoundary, "Straight angle"); }); +test("classifies reflex angle boundary ", () => { + const reflexBoundary = getAngleType(270); + assert.equal(reflexBoundary, "Reflex angle"); +}); + +test("classifies right angle boundary ", () => { + const rightBoundary = getAngleType(90); + assert.equal(rightBoundary, "Right angle"); +}); + +test("classifies straight angle boundary ", () => { + const straightBoundary = getAngleType(180); + assert.equal(straightBoundary, "Straight angle"); +}); + test("Handles invalid angles (greater than 360)", () => { const invalidGreaterThan360 = getAngleType(400); assert.equal(invalidGreaterThan360, "Invalid angle");