From dfdbad927105d4bb6bcc537e4233a32daa3043c4 Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Thu, 19 Mar 2026 00:53:12 +0000 Subject: [PATCH 01/10] Implement getAngleType function and add tests Implement the getAngleType function to classify angles and add tests for various cases. --- .../implement/1-get-angle-type.js | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js index 9e05a871e2..1f0728dee6 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -15,12 +15,34 @@ // execute the code to ensure all tests pass. function getAngleType(angle) { - // TODO: Implement this function + function getAngleType(angle) { + if (angle <= 0 || angle >= 360) + } + + if (angle < 90) { + return "actue angle"; + } + if (angle === 90) { + return "right angle"; + } + if (angle < 180){ + return "obtuse angle"; + } + if (angle === 180){ + return "straight angle"; + } +if (angle < 360){ + return "reflext angle"; } +module.exports = getAngleType; + + + // TODO: Implement this function + // The line below allows us to load the getAngleType function into tests in other files. // This will be useful in the "rewrite tests with jest" step. -module.exports = getAngleType; + // This helper function is written to make our assertions easier to read. // If the actual output matches the target output, the test will pass @@ -35,3 +57,11 @@ function assertEquals(actualOutput, targetOutput) { // Example: Identify Right Angles const right = getAngleType(90); assertEquals(right, "Right angle"); + + // Test +assertEquals(getAngleType(45), "Acute angle"); +assertEquals(getAngleType(90), "Right angle"); +assertEquals(getAngleType(120), "Obtuse angle"); +assertEquals(getAngleType(180), "Straight angle"); +assertEquals(getAngleType(270), "Reflex angle"); +assertEquals(getAngleType(390), "invalid angle"); From f54aa1f65e5085fc62a24abac6587752b36d6f2c Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Thu, 19 Mar 2026 01:09:46 +0000 Subject: [PATCH 02/10] Implement isProperFraction function and add tests Implemented the isProperFraction function to check if the numerator is less than the denominator. Added tests for various cases including proper fractions, improper fractions, and edge cases. --- .../implement/2-is-proper-fraction.js | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js index 970cb9b641..0c4374b5cc 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -11,12 +11,16 @@ // execute the code to ensure all tests pass. function isProperFraction(numerator, denominator) { - // TODO: Implement this function + if (numerator < denominator) { +return true; + } else { + return false; + } } +module.exports = isProperFraction; // The line below allows us to load the isProperFraction function into tests in other files. // This will be useful in the "rewrite tests with jest" step. -module.exports = isProperFraction; // Here's our helper again function assertEquals(actualOutput, targetOutput) { @@ -31,3 +35,16 @@ function assertEquals(actualOutput, targetOutput) { // Example: 1/2 is a proper fraction assertEquals(isProperFraction(1, 2), true); +//Test +// Proper fraction 3/5 +assertEqual(isproperFraction(3,5), true); +assertEual(isProperFraction(4/8), true); + +//Not +assertEqual(isproperFraction(9,7),false); +assertEqual(isproperFracton(13/11),false); + +//Edge case +assertEqual(isperoperFractio(0,5),true); + + From 3be8b8854a14dbabdf4372c321069e5dd04ee0e3 Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Fri, 20 Mar 2026 20:08:24 +0000 Subject: [PATCH 03/10] Implement getCardValue function with error handling Implemented the getCardValue function to determine the value of a card based on its rank and suit. Added error handling for invalid cards and wrote initial test cases. --- .../implement/3-get-card-value.js | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js index c7559e787e..e00c4c8a7e 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js @@ -22,12 +22,27 @@ // execute the code to ensure all tests pass. function getCardValue(card) { - // TODO: Implement this function + const rank = card.slice(0, -1); + const suit = card.slice(-1); + +const vaildSuits = [""♠", "♥", "♦", "♣"]; + const vailRanks = ["A","2","3","4","5","6","7","8","9","10","J","Q","k"]; + + if (!vaildSuits.includes) || !validRanks.inculdes(rank){ + trow new Error("Invaild card"); + } + if (rank === "A") return 11; + if (rank === "J" || rank === "Q" || rank === "K") return 10; + + return Number(rank); } +module.exports = getCardValue; + + // The line below allows us to load the getCardValue function into tests in other files. // This will be useful in the "rewrite tests with jest" step. -module.exports = getCardValue; + // Helper functions to make our assertions easier to read. function assertEquals(actualOutput, targetOutput) { @@ -40,10 +55,15 @@ function assertEquals(actualOutput, targetOutput) { // TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. // Examples: assertEquals(getCardValue("9♠"), 9); +//Test +assertEquals(getCardvalue("A♠"), 11); +assertEquals(getCardEqual("J♣), 10); +assertEquals(getCardequal("10♥"), 10); // Handling invalid cards try { getCardValue("invalid"); + // This line will not be reached if an error is thrown as expected console.error("Error was not thrown for invalid card"); From 3bb3ca75bbe856e525f1f0583095352a762ff78e Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Fri, 20 Mar 2026 20:10:09 +0000 Subject: [PATCH 04/10] Correct validation logic in getCardValue function Fix typos in suit and rank validation checks, and correct error throwing. --- .../1-implement-and-rewrite-tests/implement/3-get-card-value.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js index e00c4c8a7e..ec7e644c30 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js @@ -29,7 +29,7 @@ const vaildSuits = [""♠", "♥", "♦", "♣"]; const vailRanks = ["A","2","3","4","5","6","7","8","9","10","J","Q","k"]; if (!vaildSuits.includes) || !validRanks.inculdes(rank){ - trow new Error("Invaild card"); + throw new Error("Invaild card"); } if (rank === "A") return 11; if (rank === "J" || rank === "Q" || rank === "K") return 10; From f376a888a7c1ba82678e55c023d674f498d5703b Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Sat, 21 Mar 2026 11:25:37 +0000 Subject: [PATCH 05/10] Fix typos in angle type returns --- .../implement/1-get-angle-type.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js index 1f0728dee6..4d147da262 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js @@ -20,7 +20,7 @@ function getAngleType(angle) { } if (angle < 90) { - return "actue angle"; + return "acute angle"; } if (angle === 90) { return "right angle"; @@ -32,7 +32,7 @@ function getAngleType(angle) { return "straight angle"; } if (angle < 360){ - return "reflext angle"; + return "reflex angle"; } module.exports = getAngleType; From f33a9a94e7a0e07507697206aee03e52b784ab0c Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Sat, 21 Mar 2026 11:33:15 +0000 Subject: [PATCH 06/10] Added proper fraction test Fix typos in test cases and improve assertions for the isProperFraction function. --- .../implement/2-is-proper-fraction.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js index 0c4374b5cc..7c4f1c595a 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -1,4 +1,4 @@ -// Implement a function isProperFraction, +(properfraction (// Implement a function isProperFraction, // when given two numbers, a numerator and a denominator, it should return true if // the given numbers form a proper fraction, and false otherwise. @@ -36,15 +36,17 @@ function assertEquals(actualOutput, targetOutput) { // Example: 1/2 is a proper fraction assertEquals(isProperFraction(1, 2), true); //Test -// Proper fraction 3/5 +// Proper fraction assertEqual(isproperFraction(3,5), true); -assertEual(isProperFraction(4/8), true); +assertEual(isProperFraction(4,8), true); +assertEqual(isproperfraction (-1,-2) false); + //Not -assertEqual(isproperFraction(9,7),false); +assertEqual(isproperFraction(9/7),false); assertEqual(isproperFracton(13/11),false); //Edge case -assertEqual(isperoperFractio(0,5),true); +assertEqual(isperoperFractio(0/5),true); From 61867b644c8256ed838a6f09c050656b6088164b Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Sat, 21 Mar 2026 11:40:29 +0000 Subject: [PATCH 07/10] Added proper fraction test --- .../implement/2-is-proper-fraction.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js index 7c4f1c595a..8a15c01861 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -37,16 +37,18 @@ function assertEquals(actualOutput, targetOutput) { assertEquals(isProperFraction(1, 2), true); //Test // Proper fraction -assertEqual(isproperFraction(3,5), true); +assertEqual(isProperFraction(3,5), true); assertEual(isProperFraction(4,8), true); -assertEqual(isproperfraction (-1,-2) false); +assertEqual(isproperFraction(-1,2), true); //Not -assertEqual(isproperFraction(9/7),false); -assertEqual(isproperFracton(13/11),false); +assertEqual(isproperFraction(9/7), false); +assertEqual(isproperFracton(13/11), false); +assertEqual(isProperFraction(-1,-2), false); +assertEqual(ispProperFraction(1,-2), false) //Edge case -assertEqual(isperoperFractio(0/5),true); +assertEqual(isperoperFractio(0/5), true); From 8c62675041ece1c7f708fc4c4d7c4b469c91bd7b Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Sat, 21 Mar 2026 11:44:27 +0000 Subject: [PATCH 08/10] Correct test assertions for isProperFraction Fix typos in test cases for isProperFraction function. --- .../implement/2-is-proper-fraction.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js index 8a15c01861..1659f8ac5d 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -40,13 +40,14 @@ assertEquals(isProperFraction(1, 2), true); assertEqual(isProperFraction(3,5), true); assertEual(isProperFraction(4,8), true); assertEqual(isproperFraction(-1,2), true); +assertEqual(isProperFraction(-1,-2), true); +assertEqual(ispProperFraction(1,-2), true) //Not assertEqual(isproperFraction(9/7), false); assertEqual(isproperFracton(13/11), false); -assertEqual(isProperFraction(-1,-2), false); -assertEqual(ispProperFraction(1,-2), false) + //Edge case assertEqual(isperoperFractio(0/5), true); From 5920b758b0593822257cb77d6c238d19fabe70f8 Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Sat, 21 Mar 2026 11:52:18 +0000 Subject: [PATCH 09/10] added new not proper fractions --- .../implement/2-is-proper-fraction.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js index 1659f8ac5d..f7fcfd8beb 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js @@ -47,6 +47,9 @@ assertEqual(ispProperFraction(1,-2), true) //Not assertEqual(isproperFraction(9/7), false); assertEqual(isproperFracton(13/11), false); +assertEqual(isproperFracton (19/10), false); +assertEqual(isproperFracton (17/3 ), false); + //Edge case From 3d96413dc3df9c576bbf9c073068fc459b2cbda8 Mon Sep 17 00:00:00 2001 From: Seti Mussa Date: Sat, 21 Mar 2026 11:59:24 +0000 Subject: [PATCH 10/10] Fix typos in getCardValue function --- .../implement/3-get-card-value.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js index ec7e644c30..3e20d3eb69 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js @@ -25,10 +25,10 @@ function getCardValue(card) { const rank = card.slice(0, -1); const suit = card.slice(-1); -const vaildSuits = [""♠", "♥", "♦", "♣"]; +const vaildSuits = ["♠", "♥", "♦", "♣"]; const vailRanks = ["A","2","3","4","5","6","7","8","9","10","J","Q","k"]; - if (!vaildSuits.includes) || !validRanks.inculdes(rank){ + if (!vaildSuits.includes(suit) || !validRanks.inculdes(rank)){ throw new Error("Invaild card"); } if (rank === "A") return 11;