From e4e4db05fa26aa80e00dbb70115fd961a5760406 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Mon, 6 Jul 2026 23:46:21 +0100 Subject: [PATCH 01/52] write code for the angle conditions checking --- .../implement/1-get-angle-type.js | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) 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..ab84303854 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,7 +15,31 @@ // execute the code to ensure all tests pass. function getAngleType(angle) { - // TODO: Implement this function + // first converting conditions into variables + const acuteAngle = (angle > 0 && angle < 90); + const rightAngle = (angle === 90); + const obtuseAngle = (angle > 90 && angle < 180); + const straightAngle = (angle === 180); + const reflexAngle = (angle > 180 && angle < 360); + const zeroAngle = (angle === 0); + + + if (rightAngle) { + // checking for conditions + return "Right angle"; + } else if (zeroAngle) { + return "Invalid angle"; + }else if (obtuseAngle) { + return "Obtuse angle"; + } else if (straightAngle) { + return "Straight angle"; + } else if (reflexAngle) { + return "Reflex angle"; + } else if (acuteAngle) { + return "Acute angle"; + } else if (angle === zeroAngle || angle != acuteAngle || angle != rightAngle || angle != obtuseAngle || angle != straightAngle || angle != reflexAngle) { + return "Invalid angle"; + } } // The line below allows us to load the getAngleType function into tests in other files. @@ -35,3 +59,4 @@ function assertEquals(actualOutput, targetOutput) { // Example: Identify Right Angles const right = getAngleType(90); assertEquals(right, "Right angle"); + From cd130fbebdfbe9c2451dff7084815cec70307535 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Mon, 6 Jul 2026 23:51:27 +0100 Subject: [PATCH 02/52] add tests for 45 and 120 --- .../implement/1-get-angle-type.js | 6 ++++++ 1 file changed, 6 insertions(+) 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 ab84303854..22a0a109dd 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 @@ -60,3 +60,9 @@ function assertEquals(actualOutput, targetOutput) { const right = getAngleType(90); assertEquals(right, "Right angle"); +const acute = getAngleType(45); +assertEquals(acute, "Acute angle"); + +const obtuse = getAngleType(120); +assertEquals(obtuse, "Obtuse angle"); + From cfd5e9e37967a1291eb8ade572c4c164cb493df9 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Mon, 6 Jul 2026 23:54:42 +0100 Subject: [PATCH 03/52] add tests for 180 and 270 --- .../implement/1-get-angle-type.js | 6 ++++++ 1 file changed, 6 insertions(+) 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 22a0a109dd..5cd5b4e3f3 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 @@ -66,3 +66,9 @@ assertEquals(acute, "Acute angle"); const obtuse = getAngleType(120); assertEquals(obtuse, "Obtuse angle"); +const straight = getAngleType(180); +assertEquals(straight, "Straight angle"); + +const reflex = getAngleType(270); +assertEquals(reflex, "Reflex angle"); + From c3e2ecfd8de056ece3d957b2e76258739a8153bb Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 9 Jul 2026 12:44:35 +0100 Subject: [PATCH 04/52] add 360, 0, -1, tests --- .../implement/1-get-angle-type.js | 8 ++++++++ 1 file changed, 8 insertions(+) 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 5cd5b4e3f3..454bf67930 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 @@ -72,3 +72,11 @@ assertEquals(straight, "Straight angle"); const reflex = getAngleType(270); assertEquals(reflex, "Reflex angle"); +const invalidAngle1 = getAngleType(360); +assertEquals(invalidAngle1, "Invalid angle"); + +const invalidAngle2 = getAngleType(0); +assertEquals(invalidAngle2, "Invalid angle"); + +const invalidAngle3 = getAngleType(-1); +assertEquals(invalidAngle3, "Invalid angle"); \ No newline at end of file From a68ed34fcb5a6b3121ca310d6720c1d2a661a847 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 9 Jul 2026 13:54:22 +0100 Subject: [PATCH 05/52] write code and tests --- .../implement/2-is-proper-fraction.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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..510096cb1b 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,9 +11,14 @@ // execute the code to ensure all tests pass. function isProperFraction(numerator, denominator) { - // TODO: Implement this function + if (numerator / denominator < 1) { + return true;// if numerator is smaller than denominator - return true + } else { + return false;//return false if numerator if bigger that denominator + } } + // 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; @@ -31,3 +36,12 @@ function assertEquals(actualOutput, targetOutput) { // Example: 1/2 is a proper fraction assertEquals(isProperFraction(1, 2), true); + +// Example: 2/3 is a proper fraction +assertEquals(isProperFraction(2, 3), true); + +// Example: 4/2 is not a proper fraction +assertEquals(isProperFraction(4, 2), false); + +// Example: 4/4 is not a proper fraction +assertEquals(isProperFraction(4, 4), false); \ No newline at end of file From f07846cae9cfc9b8583daaa268d447d195977e9f Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 9 Jul 2026 14:58:33 +0100 Subject: [PATCH 06/52] write code to check conditions --- .../implement/3-get-card-value.js | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 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 ff5c532e1d..4fb4f02598 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,9 +22,21 @@ // execute the code to ensure all tests pass. function getCardValue(card) { - // TODO: Implement this function + let cardValue = card.slice(0, -1) + let cardValue1 = 0 + if (Number(cardValue.match(/\d+(\.\d+)?/g)) < 10 && Number(cardValue.match(/\d+(\.\d+)?/g)) > 1) { + return Number(cardValue); + } else if (cardValue === "A") { + return 11; + } else if (cardValue === "K" || cardValue === "Q" || cardValue === "J") { + return 10; + } else { + return cardValue1 = "Invalid card format"; + } + console.log(cardValue1) } +console.log(getCardValue("00")); // 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; @@ -41,6 +53,18 @@ function assertEquals(actualOutput, targetOutput) { // Examples: assertEquals(getCardValue("9♠"), 9); +assertEquals(getCardValue("A♠"), 11); + +assertEquals(getCardValue("K♠"), 10); + +assertEquals(getCardValue("Q♠"), 10); + +assertEquals(getCardValue("J♠"), 10); + +assertEquals(getCardValue("Nq"), "Invalid card format"); + +assertEquals(getCardValue("00"), "Invalid card format"); + // Handling invalid cards try { getCardValue("invalid"); From 191b8902b631e7c868a609b8b4965dfb8630c1e2 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 10 Jul 2026 11:16:27 +0100 Subject: [PATCH 07/52] rewrite main function --- .../implement/3-get-card-value.js | 48 ++++++++++++++----- 1 file changed, 35 insertions(+), 13 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 4fb4f02598..d1fc15a0f5 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,21 +22,43 @@ // execute the code to ensure all tests pass. function getCardValue(card) { - let cardValue = card.slice(0, -1) - let cardValue1 = 0 - if (Number(cardValue.match(/\d+(\.\d+)?/g)) < 10 && Number(cardValue.match(/\d+(\.\d+)?/g)) > 1) { - return Number(cardValue); - } else if (cardValue === "A") { - return 11; - } else if (cardValue === "K" || cardValue === "Q" || cardValue === "J") { - return 10; + const suit = ["♠", "♥", "♦", "♣"]; // array with suits + const rank = [ + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "A", + "K", + "Q", + "J", + ]; // array with ranks + const tenPointsFaceCards = ["K", "Q", "J"]; //cards with value of 10 points + + const rank1 = card.slice(0, -1); //takes the firs part of card + const suit1 = card.slice(-1); //takes "suit" secnd part of card + const isCardValid = suit.includes(suit1) && rank.includes(rank1); //conditions where card is considered valid + + //conditional statement to check validity of the card + if (!isCardValid) { + throw new Error("Error thrown for invalid card 🎉"); + } + + //conditional statements to check what value to return depending on the card value + if (rank1 === "A") { + return 11; + } else if (tenPointsFaceCards.includes(rank1)) { + return 10; } else { - return cardValue1 = "Invalid card format"; + return Number(rank1); } - console.log(cardValue1) } -console.log(getCardValue("00")); // 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; @@ -61,9 +83,9 @@ assertEquals(getCardValue("Q♠"), 10); assertEquals(getCardValue("J♠"), 10); -assertEquals(getCardValue("Nq"), "Invalid card format"); +assertEquals(getCardValue("Nq"), "Error thrown for invalid card 🎉"); -assertEquals(getCardValue("00"), "Invalid card format"); +//assertEquals(getCardValue("00"), "Invalid card format"); // Handling invalid cards try { From 9c498b62f425a85c3f54a2189be83ae114b24b03 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 10 Jul 2026 12:46:55 +0100 Subject: [PATCH 08/52] add tests for all cases --- .../implement/3-get-card-value.js | 80 ++++++++++++++++++- 1 file changed, 77 insertions(+), 3 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 d1fc15a0f5..31b2edb54f 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 @@ -46,7 +46,7 @@ function getCardValue(card) { //conditional statement to check validity of the card if (!isCardValid) { - throw new Error("Error thrown for invalid card 🎉"); + throw new Error("Invalid card format"); } //conditional statements to check what value to return depending on the card value @@ -73,6 +73,7 @@ function assertEquals(actualOutput, targetOutput) { // TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. // Examples: + assertEquals(getCardValue("9♠"), 9); assertEquals(getCardValue("A♠"), 11); @@ -83,9 +84,11 @@ assertEquals(getCardValue("Q♠"), 10); assertEquals(getCardValue("J♠"), 10); -assertEquals(getCardValue("Nq"), "Error thrown for invalid card 🎉"); +assertEquals(getCardValue("10♣"), 10); -//assertEquals(getCardValue("00"), "Invalid card format"); +//assertEquals(getCardValue("11♣"), "Invalid card format"); i find that +// this test will not work, because my function is throwing error before the program +// reaches the assertEquals function. // Handling invalid cards try { @@ -98,3 +101,74 @@ try { } // What other invalid card cases can you think of? +try { + getCardValue("11♣"); // testing with "11♣" the error will be thrown because "11" is not a valid rank + + // This line will not be reached if an error is thrown as expected + console.error("Error was not thrown for invalid card 😢"); +} catch (e) { + console.log("Error thrown for invalid card 🎉"); +} + +try { + getCardValue("A"); // testing with "A" the error will be thrown because there is no suit + + // This line will not be reached if an error is thrown as expected + console.error("Error was not thrown for invalid card 😢"); +} catch (e) { + console.log("Error thrown for invalid card 🎉"); +} + +try { + getCardValue("10"); // testing with "10" the error will be thrown because there is no suit + + // This line will not be reached if an error is thrown as expected + console.error("Error was not thrown for invalid card 😢"); +} catch (e) { + console.log("Error thrown for invalid card 🎉"); +} + +try { + getCardValue("1♣"); // testing with "1♣" the error will be thrown because "1" is not a valid rank + + // This line will not be reached if an error is thrown as expected + console.error("Error was not thrown for invalid card 😢"); +} catch (e) { + console.log("Error thrown for invalid card 🎉"); +} + +try { + getCardValue("A5"); // testing with "A5" the error will be thrown because "5" is not a valid suit + + // This line will not be reached if an error is thrown as expected + console.error("Error was not thrown for invalid card 😢"); +} catch (e) { + console.log("Error thrown for invalid card 🎉"); +} + +try { + getCardValue("♣6"); // testing with "♣6" the error will be thrown because "6" is not a valid suit and "♣" is not a valid rank + + // This line will not be reached if an error is thrown as expected + console.error("Error was not thrown for invalid card 😢"); +} catch (e) { + console.log("Error thrown for invalid card 🎉"); +} + +try { + getCardValue("@@"); // testing with "@@" the error will be thrown because "@" is not a valid rank or suit + + // This line will not be reached if an error is thrown as expected + console.error("Error was not thrown for invalid card 😢"); +} catch (e) { + console.log("Error thrown for invalid card 🎉"); +} + +try { + getCardValue("-6♣"); // testing with "-6♣" (negative number) the error will be thrown because "-" is not a valid rank + + // This line will not be reached if an error is thrown as expected + console.error("Error was not thrown for invalid card 😢"); +} catch (e) { + console.log("Error thrown for invalid card 🎉"); +} From 7e7fe32b5fe9a9bcdf04adb72509b55c9aba5e90 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 10 Jul 2026 13:49:36 +0100 Subject: [PATCH 09/52] add empty string test --- .../implement/3-get-card-value.js | 9 +++++++++ 1 file changed, 9 insertions(+) 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 31b2edb54f..b7b9e7ec9c 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 @@ -172,3 +172,12 @@ try { } catch (e) { console.log("Error thrown for invalid card 🎉"); } + +try { + getCardValue(""); // testing with "" the error will be thrown because "" is not a valid card + + // This line will not be reached if an error is thrown as expected + console.error("Error was not thrown for invalid card 😢"); +} catch (e) { + console.log("Error thrown for invalid card 🎉"); +} From d6568e728e7066e6e939e03eeb7961e5c2ed6beb Mon Sep 17 00:00:00 2001 From: vmoratti Date: Sun, 12 Jul 2026 12:15:21 +0100 Subject: [PATCH 10/52] write test for the right and obtuse angle --- .../implement/1-get-angle-type.js | 2 +- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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 454bf67930..cfbb7be7e1 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 @@ -79,4 +79,4 @@ const invalidAngle2 = getAngleType(0); assertEquals(invalidAngle2, "Invalid angle"); const invalidAngle3 = getAngleType(-1); -assertEquals(invalidAngle3, "Invalid angle"); \ No newline at end of file +assertEquals(invalidAngle3, "Invalid angle"); diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index d777f348d3..f572a3e768 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -14,7 +14,15 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { }); // Case 2: Right angle +test(`should return "Right angle" when (angle === 90)`, () => { + //test right angle at 9 degrees + expect(getAngleType(90)).toEqual("Right angle"); +}); + // Case 3: Obtuse angles +test(`should return "Obtuse angle" when (90 > angle > 180)`, () => { + expect(getAngleType(91)).toEqual("Obtuse angle"); +}); // Case 4: Straight angle // Case 5: Reflex angles // Case 6: Invalid angles From d23d3a6ca349dd3e45bd493fa79e5d9adf303e98 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Sun, 12 Jul 2026 12:31:26 +0100 Subject: [PATCH 11/52] add straight angle, and reflex angle tests --- .../1-get-angle-type.test.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index f572a3e768..21d981d4c8 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -15,14 +15,28 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { // Case 2: Right angle test(`should return "Right angle" when (angle === 90)`, () => { - //test right angle at 9 degrees + //test right angle at 90 degrees expect(getAngleType(90)).toEqual("Right angle"); }); // Case 3: Obtuse angles test(`should return "Obtuse angle" when (90 > angle > 180)`, () => { + //test various obtuse cases, including border cases expect(getAngleType(91)).toEqual("Obtuse angle"); + expect(getAngleType(120)).toEqual("Obtuse angle"); + expect(getAngleType(179)).toEqual("Obtuse angle"); }); // Case 4: Straight angle +test(`should return "Straight angle" when (angle ==== 180)`, () => { + //test for straight angle at 180 degrees + expect(getAngleType(180)).toEqual("Straight angle"); +}) + // Case 5: Reflex angles +test(`should return "Reflex angle" when (180 > angle > 360)`, () => { + //test for various reflex angle between 181 and 359 degrees + expect(getAngleType(181)).toEqual("Reflex angle"); + expect(getAngleType(210)).toEqual("Reflex angle"); + expect(getAngleType(359)).toEqual("Reflex angle"); +}) // Case 6: Invalid angles From 75b5e8315fb9eb8520cad49585563e2f0e80298e Mon Sep 17 00:00:00 2001 From: vmoratti Date: Sun, 12 Jul 2026 12:58:23 +0100 Subject: [PATCH 12/52] add invalid test cases --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index 21d981d4c8..89384c9d8f 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -30,7 +30,7 @@ test(`should return "Obtuse angle" when (90 > angle > 180)`, () => { test(`should return "Straight angle" when (angle ==== 180)`, () => { //test for straight angle at 180 degrees expect(getAngleType(180)).toEqual("Straight angle"); -}) +}); // Case 5: Reflex angles test(`should return "Reflex angle" when (180 > angle > 360)`, () => { @@ -38,5 +38,13 @@ test(`should return "Reflex angle" when (180 > angle > 360)`, () => { expect(getAngleType(181)).toEqual("Reflex angle"); expect(getAngleType(210)).toEqual("Reflex angle"); expect(getAngleType(359)).toEqual("Reflex angle"); -}) +}); // Case 6: Invalid angles +test(`should return "Invalid angle" when (angle >= 0 || angle >= 360 || angle === isNan())`, () => { + //tests for various invalid angles + expect(getAngleType(0)).toEqual("Invalid angle"); + expect(getAngleType(360)).toEqual("Invalid angle"); + expect(getAngleType(-10)).toEqual("Invalid angle"); + expect(getAngleType(380)).toEqual("Invalid angle"); + expect(getAngleType(NaN)).toEqual("Invalid angle"); +}); From 0fdd2729930e67f41f41457241a66146dc5aff87 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Sun, 12 Jul 2026 13:01:55 +0100 Subject: [PATCH 13/52] add floating point test cases --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index 89384c9d8f..a0f476a183 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -10,7 +10,7 @@ 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"); + expect(getAngleType(89.9)).toEqual("Acute angle"); }); // Case 2: Right angle @@ -24,7 +24,7 @@ test(`should return "Obtuse angle" when (90 > angle > 180)`, () => { //test various obtuse cases, including border cases expect(getAngleType(91)).toEqual("Obtuse angle"); expect(getAngleType(120)).toEqual("Obtuse angle"); - expect(getAngleType(179)).toEqual("Obtuse angle"); + expect(getAngleType(179.9)).toEqual("Obtuse angle"); }); // Case 4: Straight angle test(`should return "Straight angle" when (angle ==== 180)`, () => { @@ -37,7 +37,7 @@ test(`should return "Reflex angle" when (180 > angle > 360)`, () => { //test for various reflex angle between 181 and 359 degrees expect(getAngleType(181)).toEqual("Reflex angle"); expect(getAngleType(210)).toEqual("Reflex angle"); - expect(getAngleType(359)).toEqual("Reflex angle"); + expect(getAngleType(359.9)).toEqual("Reflex angle"); }); // Case 6: Invalid angles test(`should return "Invalid angle" when (angle >= 0 || angle >= 360 || angle === isNan())`, () => { @@ -48,3 +48,6 @@ test(`should return "Invalid angle" when (angle >= 0 || angle >= 360 || angle == expect(getAngleType(380)).toEqual("Invalid angle"); expect(getAngleType(NaN)).toEqual("Invalid angle"); }); + + + From c278f255912b842902b50baf6e517923d8244531 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Sun, 12 Jul 2026 14:28:58 +0100 Subject: [PATCH 14/52] add test for zero numerator --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 7f087b2ba1..8f94feee74 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -4,7 +4,12 @@ const isProperFraction = require("../implement/2-is-proper-fraction"); // TODO: Write tests in Jest syntax to cover all combinations of positives, negatives, zeros, and other categories. -// Special case: numerator is zero +// Special case: denominator is zero test(`should return false when denominator is zero`, () => { expect(isProperFraction(1, 0)).toEqual(false); }); + +// Special case: numerator is zero +test(`should return true when numerator is zero `, () => { + expect(isProperFraction(0, 2)).toEqual(true); +}); From 344841350f7498c334f9f0855f972a94492f1e83 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Sun, 12 Jul 2026 23:53:10 +0100 Subject: [PATCH 15/52] add negative tests --- .../2-is-proper-fraction.test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 8f94feee74..bf3339a96e 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -13,3 +13,17 @@ test(`should return false when denominator is zero`, () => { test(`should return true when numerator is zero `, () => { expect(isProperFraction(0, 2)).toEqual(true); }); + +// negative numerator and positive denominator +test(`should return true when numerator is negative and denominator is positive`, () => { + expect(isProperFraction(-1, 2)).toEqual(true); +}); + +// positive numerator, negative denominator +test(` should return false when numerator is positive and denominator is negative`, () => { + expect(isProperFraction(1, -2)).toEqual(true); +}) + + + + From 14335088c68a8e4e04a4a9f168a55ccda2c9c0fd Mon Sep 17 00:00:00 2001 From: vmoratti Date: Mon, 13 Jul 2026 14:23:46 +0100 Subject: [PATCH 16/52] add ablolute methode to function --- .../implement/2-is-proper-fraction.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 510096cb1b..faa27ba337 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,7 +11,7 @@ // execute the code to ensure all tests pass. function isProperFraction(numerator, denominator) { - if (numerator / denominator < 1) { + if (Math.abs(numerator / denominator) < 1) { return true;// if numerator is smaller than denominator - return true } else { return false;//return false if numerator if bigger that denominator From e81fc428ff66a3cbcc4fbc7ea71e0368096352ff Mon Sep 17 00:00:00 2001 From: vmoratti Date: Mon, 13 Jul 2026 14:28:12 +0100 Subject: [PATCH 17/52] add tests --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index bf3339a96e..63efa6fa65 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -24,6 +24,8 @@ test(` should return false when numerator is positive and denominator is negativ expect(isProperFraction(1, -2)).toEqual(true); }) +//negative numerator and denominator where numerator is smaller +test(`should return false whe`) From 08cc18c4567952695c4fc6e86b8351a25cdbd293 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Mon, 13 Jul 2026 14:36:39 +0100 Subject: [PATCH 18/52] add negative numbers tests --- .../2-is-proper-fraction.test.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 63efa6fa65..6c3498f5dc 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -24,8 +24,12 @@ test(` should return false when numerator is positive and denominator is negativ expect(isProperFraction(1, -2)).toEqual(true); }) -//negative numerator and denominator where numerator is smaller -test(`should return false whe`) - - +//negative numerator and denominator where numerator is smaller than denominator +test(`should return true when numerator is negative and denominator is negative and numerator is smaller than denominator`, () => { + expect(isProperFraction(-1, -2)).toEqual(true); +}); +//negative numerator and denominator where numerator is bigger than denominator +test(`should return false when numerator is negative and denominator is negative and numerator is bigger than denominator`, () => { + expect(isProperFraction(-2, -1)).toEqual(false); +}); \ No newline at end of file From 366cb56688e9c1bbc22f5d0aae20de7dfe92e3a2 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Mon, 13 Jul 2026 14:45:08 +0100 Subject: [PATCH 19/52] add positive tests --- .../2-is-proper-fraction.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 6c3498f5dc..0eb31f570b 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -32,4 +32,14 @@ test(`should return true when numerator is negative and denominator is negative //negative numerator and denominator where numerator is bigger than denominator test(`should return false when numerator is negative and denominator is negative and numerator is bigger than denominator`, () => { expect(isProperFraction(-2, -1)).toEqual(false); +}); + +//positive numerator and denominator where numerator is smaller +test(`should return true when numerator is smaller`, () => { + expect(isProperFraction(1, 2)).toEqual(true); +}); + +// positive numerator and denominator, numerator is larger +test(`should return false when numerator is larger`, () => { + expect(isProperFraction(4, 2)).toEqual(false); }); \ No newline at end of file From 2ef1a20e196da5cab2fe08786b79c4134326f5f3 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Mon, 13 Jul 2026 15:28:01 +0100 Subject: [PATCH 20/52] add final tests --- .../2-is-proper-fraction.test.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 0eb31f570b..418d5f587f 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -14,6 +14,11 @@ test(`should return true when numerator is zero `, () => { expect(isProperFraction(0, 2)).toEqual(true); }); +// numerator and denominator are both zero +test(`should return false when numerator and denominator are both zero`, () => { + expect(isProperFraction(0, 0)).toEqual(false); +}); + // negative numerator and positive denominator test(`should return true when numerator is negative and denominator is positive`, () => { expect(isProperFraction(-1, 2)).toEqual(true); @@ -42,4 +47,19 @@ test(`should return true when numerator is smaller`, () => { // positive numerator and denominator, numerator is larger test(`should return false when numerator is larger`, () => { expect(isProperFraction(4, 2)).toEqual(false); +}); + +// equal numerator and denominator +test(`should return false when numerator and denominator are equal`, () => { + expect(isProperFraction(4, 4)).toEqual(false); +}); + +// numerator and denominator are both floating point numbers, numerator is smaller +test(`should return true when numerator and denominator are both floating point numbers and numerator is smaller`, () => { + expect(isProperFraction(1.5, 2.5)).toEqual(true); +}); + +// numerator and denominator are both floating point numbers, numerator is larger +test(`should return false when numerator and denominator are both floating point numbers and numerator is larger`, () => { + expect(isProperFraction(2.5, 1.5)).toEqual(false); }); \ No newline at end of file From 55113f3c2a9107448f3dd1eb3b17254c6d00e4b9 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Mon, 13 Jul 2026 15:35:24 +0100 Subject: [PATCH 21/52] add tests for number 2 and 10 --- .../rewrite-tests-with-jest/3-get-card-value.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index cf7f9dae2e..e3900a6546 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -9,6 +9,16 @@ test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); +// Case 2: Number cards (2-10) +test(`Should return 2 when given a 2 card`, () => { + expect(getCardValue("2♠")).toEqual(2); +}); + +// Case 3: Number cards (2-10) +test(`Should return 10 when given a 10 card`, () => { + expect(getCardValue("10♠")).toEqual(10); +}); + // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) From 0527fe3c65d3d33194091fd7fbfd6c339b4bc76a Mon Sep 17 00:00:00 2001 From: vmoratti Date: Mon, 13 Jul 2026 15:38:40 +0100 Subject: [PATCH 22/52] add tests for J, Q, K QQ quit --- .../3-get-card-value.test.js | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index e3900a6546..17f8c47a28 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -3,7 +3,10 @@ const getCardValue = require("../implement/3-get-card-value"); // TODO: Write tests in Jest syntax to cover all possible outcomes. - +// Suggestion: Group the remaining test data into these categories: +// Number Cards (2-10) +// Face Cards (J, Q, K) +// Invalid Cards // Case 1: Ace (A) test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); @@ -19,6 +22,21 @@ test(`Should return 10 when given a 10 card`, () => { expect(getCardValue("10♠")).toEqual(10); }); +// Case 4: Face cards (J, Q, K) +test(`Should return 10 when given a J card`, () => { + expect(getCardValue("J♠")).toEqual(10); +}); + +// Case 5: Face cards (J, Q, K) +test(`Should return 10 when given a Q card`, () => { + expect(getCardValue("Q♠")).toEqual(10); +}); + +// Case 6: Face cards (J, Q, K) +test(`Should return 10 when given a K card`, () => { + expect(getCardValue("K♠")).toEqual(10); +}); + // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) From 7e5f326117986e8dcca615f007c5653ba515e024 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 14 Jul 2026 17:22:55 +0100 Subject: [PATCH 23/52] add invalid card tests --- .../3-get-card-value.test.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index 17f8c47a28..02e4ddbed3 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -7,6 +7,7 @@ const getCardValue = require("../implement/3-get-card-value"); // Number Cards (2-10) // Face Cards (J, Q, K) // Invalid Cards + // Case 1: Ace (A) test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); @@ -37,12 +38,16 @@ test(`Should return 10 when given a K card`, () => { expect(getCardValue("K♠")).toEqual(10); }); -// Suggestion: Group the remaining test data into these categories: -// Number Cards (2-10) -// Face Cards (J, Q, K) -// Invalid Cards - +// Invalid cases +test(`should throw an error with message "Invalid card format" when given invalid card`, () => { + expect(() => getCardValue("1♠")).toThrow("Invalid card format"); + expect(() => getCardValue("11♥")).toThrow("Invalid card format"); + expect(() => getCardValue("A1")).toThrow("Invalid card format"); + expect(() => getCardValue("1A")).toThrow("Invalid card format"); + expect(() => getCardValue("♣10")).toThrow("Invalid card format"); + expect(() => getCardValue("$$")).toThrow("Invalid card format"); + expect(() => getCardValue("-5♣")).toThrow("Invalid card format"); +}); // 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 cdef4817f7dff9491b463e201419693de7e5c11c Mon Sep 17 00:00:00 2001 From: vmoratti Date: Tue, 14 Jul 2026 17:33:21 +0100 Subject: [PATCH 24/52] add more number tests --- .../3-get-card-value.test.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index 02e4ddbed3..b81ab54c77 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -13,12 +13,19 @@ test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); -// Case 2: Number cards (2-10) -test(`Should return 2 when given a 2 card`, () => { +// Case 2: Number cards (2-9) +test(`Should return corresponding number when given a number card`, () => { expect(getCardValue("2♠")).toEqual(2); + expect(getCardValue("3♠")).toEqual(3); + expect(getCardValue("4♠")).toEqual(4); + expect(getCardValue("5♠")).toEqual(5); + expect(getCardValue("6♠")).toEqual(6); + expect(getCardValue("7♠")).toEqual(7); + expect(getCardValue("8♠")).toEqual(8); + expect(getCardValue("9♠")).toEqual(9); }); -// Case 3: Number cards (2-10) +// Case 3: Number cards (10) test(`Should return 10 when given a 10 card`, () => { expect(getCardValue("10♠")).toEqual(10); }); From 376602fe3dec154fae2851bc47409a8645f97abc Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 16 Jul 2026 08:50:08 +0100 Subject: [PATCH 25/52] write countChar() function --- Sprint-3/2-practice-tdd/count.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Sprint-3/2-practice-tdd/count.js b/Sprint-3/2-practice-tdd/count.js index 95b6ebb7d4..e956721c1e 100644 --- a/Sprint-3/2-practice-tdd/count.js +++ b/Sprint-3/2-practice-tdd/count.js @@ -1,5 +1,11 @@ function countChar(stringOfCharacters, findCharacter) { - return 5 -} + let count = 0; + for (let char of stringOfCharacters) { + if (char === findCharacter) { + count ++; + } + } + return count +} module.exports = countChar; From c17d0e6f3468fe18501cf989aae70e9b81bf282c Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 16 Jul 2026 10:17:36 +0100 Subject: [PATCH 26/52] write no occurrences test --- Sprint-3/2-practice-tdd/count.test.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Sprint-3/2-practice-tdd/count.test.js b/Sprint-3/2-practice-tdd/count.test.js index 179ea0ddf7..4bb07d346d 100644 --- a/Sprint-3/2-practice-tdd/count.test.js +++ b/Sprint-3/2-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 detect no instances of a given character", () => { + const str = "aaaaa"; + const char = "b"; + const count = countChar(str, char); + expect(count).toEqual(0); +}) + From 6f7cc83d307f455bee234a4c6247a283a7a89774 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 16 Jul 2026 17:53:00 +0100 Subject: [PATCH 27/52] write a complete function to check for endings --- Sprint-3/2-practice-tdd/get-ordinal-number.js | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Sprint-3/2-practice-tdd/get-ordinal-number.js b/Sprint-3/2-practice-tdd/get-ordinal-number.js index f95d71db13..02641e8066 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.js @@ -1,5 +1,25 @@ function getOrdinalNumber(num) { - return "1st"; + if (num % 100 === 11) { + return `${num}th` // 11 is a special case that should return "th" instead of "st". % 100 will return 11 for any number ending in 11, such as 111, 211, etc. + } else if (num % 10 === 1) { + return `${num}st`; // If the number ends with 1, except those ending with 11, return "st". + } else if (num % 10 === 2) { + return `${num}nd` + } else if (num % 10 === 3) { + return `${num}rd` // If the number ends with 2, return "nd". If the number ends with 3, return "rd". + } else { + return `${num}th` // For all other cases, return "th". + } } module.exports = getOrdinalNumber; + +console.log(getOrdinalNumber(1)); +console.log(getOrdinalNumber(2)); +console.log(getOrdinalNumber(3)); +console.log(getOrdinalNumber(4)); +console.log(getOrdinalNumber(11)); +console.log(getOrdinalNumber(21)); +console.log(getOrdinalNumber(52)); +console.log(getOrdinalNumber(63)); +console.log(getOrdinalNumber(111)) From d5357cde0f914204b2051f9f5a31af1e83de4eee Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 16 Jul 2026 19:48:12 +0100 Subject: [PATCH 28/52] correct function --- Sprint-3/2-practice-tdd/get-ordinal-number.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/Sprint-3/2-practice-tdd/get-ordinal-number.js b/Sprint-3/2-practice-tdd/get-ordinal-number.js index 02641e8066..56e599817b 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.js @@ -1,14 +1,18 @@ function getOrdinalNumber(num) { - if (num % 100 === 11) { - return `${num}th` // 11 is a special case that should return "th" instead of "st". % 100 will return 11 for any number ending in 11, such as 111, 211, etc. + if (num % 100 === 11) { + return `${num}th`; + } else if (num % 100 === 12) { + return `${num}th`; + } else if (num % 100 === 13) { + return `${num}th`; } else if (num % 10 === 1) { - return `${num}st`; // If the number ends with 1, except those ending with 11, return "st". + return `${num}st`; } else if (num % 10 === 2) { return `${num}nd` } else if (num % 10 === 3) { - return `${num}rd` // If the number ends with 2, return "nd". If the number ends with 3, return "rd". + return `${num}rd` } else { - return `${num}th` // For all other cases, return "th". + return `${num}th` } } @@ -19,7 +23,11 @@ console.log(getOrdinalNumber(2)); console.log(getOrdinalNumber(3)); console.log(getOrdinalNumber(4)); console.log(getOrdinalNumber(11)); +console.log(getOrdinalNumber(12)); +console.log(getOrdinalNumber(13)); console.log(getOrdinalNumber(21)); console.log(getOrdinalNumber(52)); console.log(getOrdinalNumber(63)); console.log(getOrdinalNumber(111)) + + From 88ecb07c2fe2f6887355d442edbc2e413fe9ae88 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 16 Jul 2026 19:59:26 +0100 Subject: [PATCH 29/52] add tests for numbers ending on 2, and on 3 --- Sprint-3/2-practice-tdd/get-ordinal-number.test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Sprint-3/2-practice-tdd/get-ordinal-number.test.js b/Sprint-3/2-practice-tdd/get-ordinal-number.test.js index adfa58560f..3cc05c48eb 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.test.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.test.js @@ -18,3 +18,15 @@ 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 return 'nd' for numbers ending with 2`, () => { + expect(getOrdinalNumber(2)).toEqual("2nd"); + expect(getOrdinalNumber(22)).toEqual("22nd"); + expect(getOrdinalNumber(122)).toEqual("122nd"); +}) + +test(`should add 'rd' for numbers ending with 3`, () => { + expect(getOrdinalNumber(3)).toEqual("3rd"); + expect(getOrdinalNumber(23)).toEqual("23rd"); + expect(getOrdinalNumber(123)).toEqual("123rd"); +}) + From b19e7d6298361b2ba7e590394987de6ab77d99bd Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 16 Jul 2026 20:21:57 +0100 Subject: [PATCH 30/52] add tests --- .../2-practice-tdd/get-ordinal-number.test.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Sprint-3/2-practice-tdd/get-ordinal-number.test.js b/Sprint-3/2-practice-tdd/get-ordinal-number.test.js index 3cc05c48eb..b426707ff5 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.test.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.test.js @@ -18,15 +18,39 @@ test("should append 'st' for numbers ending with 1, except those ending with 11" expect(getOrdinalNumber(21)).toEqual("21st"); expect(getOrdinalNumber(131)).toEqual("131st"); }); + +//Case 2: Numbers ending with 2 (but not 12) +// When the number ends with 2, except those ending with 12, +// Then the function should return a string by appending "nd" to the number. test(`should return 'nd' for numbers ending with 2`, () => { expect(getOrdinalNumber(2)).toEqual("2nd"); expect(getOrdinalNumber(22)).toEqual("22nd"); expect(getOrdinalNumber(122)).toEqual("122nd"); }) +//Case 3: Numbers ending with 3 (but not 13) +// When the number ends with 3, except those ending with 13, +// Then the function should return a string by appending "rd" to the number. test(`should add 'rd' for numbers ending with 3`, () => { expect(getOrdinalNumber(3)).toEqual("3rd"); expect(getOrdinalNumber(23)).toEqual("23rd"); expect(getOrdinalNumber(123)).toEqual("123rd"); }) +//Case 4: Numbers ending with 11, 12, 13. +// When the number ends with 11, 12 and 13, +// Then the function should return a string by appending "th" to the number. + test(`should add 'th' to exceptions like 11, 12 and 13`, () => { + expect(getOrdinalNumber(11)).toEqual("11th"); + expect(getOrdinalNumber(12)).toEqual("12th"); + expect(getOrdinalNumber(13)).toEqual("13th"); + }) + + //Case 5: All other numbers that are not ending with 1, 2, 3, and that are not 11, 12, and 13. +// the function should return corresponding string with "th" at the end +test(`should add 'th' to every case that is not exceptional`, () => { + expect(getOrdinalNumber(4)).toEqual("4th"); + expect(getOrdinalNumber(555)).toEqual("555th"); + expect(getOrdinalNumber(6666)).toEqual("6666th"); +}) + From cd93a7054edee6f80ff0774e2f6d352daefbc50f Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 16 Jul 2026 20:43:13 +0100 Subject: [PATCH 31/52] write function --- Sprint-3/2-practice-tdd/repeat-str.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index 2af0a2cea7..50c8af4c8c 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -1,7 +1,12 @@ -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"; +function repeatStr(str, num) { + var result = ""; + var i; + for (i = 0; i < num; i++) { + result += str; + } + return result; } + +console.log(repeatStr("hello", 3)) module.exports = repeatStr; From 7715334f346ebbfe462668ae810a1a576d79bc51 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 16 Jul 2026 21:00:37 +0100 Subject: [PATCH 32/52] change conditions in the function --- Sprint-3/2-practice-tdd/repeat-str.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index 50c8af4c8c..210efc15b0 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -1,12 +1,17 @@ function repeatStr(str, num) { var result = ""; var i; - for (i = 0; i < num; i++) { + if (num < 0) { + throw new Error("negative numbers are not valid") + } else if (num === 0) { + result = "" + } else { + for (i = 0; i < num; i++) { result += str; - } + }} return result; } -console.log(repeatStr("hello", 3)) +console.log(repeatStr("hello", 44)) module.exports = repeatStr; From 3ec2172834259a97d5e8c57b725b3319d0d15321 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 16 Jul 2026 21:09:22 +0100 Subject: [PATCH 33/52] add tests for 1 and 0 zero --- Sprint-3/2-practice-tdd/repeat-str.test.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Sprint-3/2-practice-tdd/repeat-str.test.js b/Sprint-3/2-practice-tdd/repeat-str.test.js index a3fc1196c4..3ce2613ea3 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.test.js +++ b/Sprint-3/2-practice-tdd/repeat-str.test.js @@ -20,11 +20,24 @@ test("should repeat the string count times", () => { // 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 just original string", () => { + const str = "hello"; + const count = 1; + const repeatedStr = repeatStr(str, count); + expect(repeatedStr).toEqual("hello"); +}); + // 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 an empty string for count of 0", () => { + const str = "hello"; + const count = 0; + const repeatedStr = repeatStr(str, count); + expect(repeatedStr).toEqual(""); +}); // Case: Handle negative count: // Given a target string `str` and a negative integer `count`, From 3301bc3f334f70e3e6a7583280521cba9d9600a9 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 10:54:36 +0100 Subject: [PATCH 34/52] write test with negative number --- Sprint-3/2-practice-tdd/repeat-str.js | 29 ++++++++++++---------- Sprint-3/2-practice-tdd/repeat-str.test.js | 7 +++++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index 210efc15b0..3a3b81b65b 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -1,17 +1,20 @@ function repeatStr(str, num) { - var result = ""; - var i; - if (num < 0) { - throw new Error("negative numbers are not valid") - } else if (num === 0) { - result = "" - } else { - for (i = 0; i < num; i++) { - result += str; - }} - return result; + var result = ""; + var i; + if (num < 0) { + throw new Error("negative numbers are not valid"); + } else if (num === 0) { + result = ""; + } else { + for (i = 0; i < num; i++) { + result += str; + } + } + return result; } - -console.log(repeatStr("hello", 44)) + +//console.log(repeatStr("hello", -1)); +//console.log(repeatStr("hello", 0)); +//console.log(repeatStr("hello", 5)) module.exports = repeatStr; diff --git a/Sprint-3/2-practice-tdd/repeat-str.test.js b/Sprint-3/2-practice-tdd/repeat-str.test.js index 3ce2613ea3..858e40e1be 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.test.js +++ b/Sprint-3/2-practice-tdd/repeat-str.test.js @@ -27,7 +27,6 @@ test("should return just original string", () => { expect(repeatedStr).toEqual("hello"); }); - // 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, @@ -43,3 +42,9 @@ test("should return an empty string for count of 0", () => { // 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. +test("should throw an error when negative number is entered", () => { + const str = "hello"; + const count = -1; + + expect(() => repeatStr(str, count)).toThrow("negative numbers are not valid"); +}); From cc6f9a325343a9cb130a374134ba8a5664e811aa Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 12:25:19 +0100 Subject: [PATCH 35/52] remove dead code --- Sprint-3/3-dead-code/exercise-1.js | 3 --- Sprint-3/3-dead-code/exercise-2.js | 5 ----- 2 files changed, 8 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index 4d09f15fa9..484e6561af 100644 --- a/Sprint-3/3-dead-code/exercise-1.js +++ b/Sprint-3/3-dead-code/exercise-1.js @@ -5,12 +5,9 @@ let testName = "Jerry"; const greeting = "hello"; function sayHello(greeting, name) { - const greetingStr = greeting + ", " + name + "!"; return `${greeting}, ${name}!`; - console.log(greetingStr); } -testName = "Aman"; const greetingMessage = sayHello(greeting, testName); diff --git a/Sprint-3/3-dead-code/exercise-2.js b/Sprint-3/3-dead-code/exercise-2.js index 56d7887c4c..b1c2362d34 100644 --- a/Sprint-3/3-dead-code/exercise-2.js +++ b/Sprint-3/3-dead-code/exercise-2.js @@ -2,13 +2,8 @@ // The countAndCapitalisePets function should continue to work for any reasonable input it's given, and you shouldn't modify the pets variable. const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"]; -const capitalisedPets = pets.map((pet) => pet.toUpperCase()); const petsStartingWithH = pets.filter((pet) => pet[0] === "h"); -function logPets(petsArr) { - petsArr.forEach((pet) => console.log(pet)); -} - function countAndCapitalisePets(petsArr) { const petCount = {}; From a36afa4fdcae758d3bcfa279fba7ef0dbf79da68 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:00:33 +0100 Subject: [PATCH 36/52] Implement getAngleType function placeholder Added a placeholder for the getAngleType function and defined conditions for angle types. --- .../1-implement-and-rewrite-tests/implement/1-get-angle-type.js | 1 + 1 file changed, 1 insertion(+) 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 cfbb7be7e1..48ef0537b0 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,6 +15,7 @@ // execute the code to ensure all tests pass. function getAngleType(angle) { + // TODO: Implement this function // first converting conditions into variables const acuteAngle = (angle > 0 && angle < 90); const rightAngle = (angle === 90); From 9bfe6a9c66b9f738426cb50d04f7d73d71142225 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:01:47 +0100 Subject: [PATCH 37/52] Implement isProperFraction function Implement isProperFraction function to check if a fraction is proper. --- .../implement/2-is-proper-fraction.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 faa27ba337..4036ee5293 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,6 +11,7 @@ // execute the code to ensure all tests pass. function isProperFraction(numerator, denominator) { + // TODO: Implement this function if (Math.abs(numerator / denominator) < 1) { return true;// if numerator is smaller than denominator - return true } else { @@ -44,4 +45,4 @@ assertEquals(isProperFraction(2, 3), true); assertEquals(isProperFraction(4, 2), false); // Example: 4/4 is not a proper fraction -assertEquals(isProperFraction(4, 4), false); \ No newline at end of file +assertEquals(isProperFraction(4, 4), false); From 41fbd9c3587356668d6b1ec242335a6e2ec590bc Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:02:42 +0100 Subject: [PATCH 38/52] Add placeholder for getCardValue function Function 'getCardValue' is marked for implementation. --- .../1-implement-and-rewrite-tests/implement/3-get-card-value.js | 1 + 1 file changed, 1 insertion(+) 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 b7b9e7ec9c..20302100a2 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,6 +22,7 @@ // execute the code to ensure all tests pass. function getCardValue(card) { + // TODO: Implement this function const suit = ["♠", "♥", "♦", "♣"]; // array with suits const rank = [ "2", From 4e8d8cc5f826d8921a0fa2b2a21563f0ea8b2259 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:03:46 +0100 Subject: [PATCH 39/52] Update test for acute angle boundary condition --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js index a0f476a183..10f83ecf40 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/1-get-angle-type.test.js @@ -10,7 +10,7 @@ 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.9)).toEqual("Acute angle"); + expect(getAngleType(89)).toEqual("Acute angle"); }); // Case 2: Right angle From c951858ed6407b1015530e4e16389c07bba9ec7c Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:20:21 +0100 Subject: [PATCH 40/52] Update tests for isProperFraction function Added a test case for zero numerator and removed duplicate test case. --- .../2-is-proper-fraction.test.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js index 418d5f587f..5dc18ea3e3 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/2-is-proper-fraction.test.js @@ -4,15 +4,17 @@ const isProperFraction = require("../implement/2-is-proper-fraction"); // 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 true when numerator is zero `, () => { + expect(isProperFraction(0, 2)).toEqual(true); +}); + // Special case: denominator is zero test(`should return false when denominator is zero`, () => { expect(isProperFraction(1, 0)).toEqual(false); }); -// Special case: numerator is zero -test(`should return true when numerator is zero `, () => { - expect(isProperFraction(0, 2)).toEqual(true); -}); + // numerator and denominator are both zero test(`should return false when numerator and denominator are both zero`, () => { @@ -62,4 +64,4 @@ test(`should return true when numerator and denominator are both floating point // numerator and denominator are both floating point numbers, numerator is larger test(`should return false when numerator and denominator are both floating point numbers and numerator is larger`, () => { expect(isProperFraction(2.5, 1.5)).toEqual(false); -}); \ No newline at end of file +}); From dacdb0fd2bb6c367895fc244fdb66fadb63665f7 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:24:31 +0100 Subject: [PATCH 41/52] add comment in the right place Updated test file to include Jest syntax and added test cases for Ace and number cards. --- .../rewrite-tests-with-jest/3-get-card-value.test.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index b81ab54c77..731c1da01b 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -3,16 +3,16 @@ const getCardValue = require("../implement/3-get-card-value"); // TODO: Write tests in Jest syntax to cover all possible outcomes. -// Suggestion: Group the remaining test data into these categories: -// Number Cards (2-10) -// Face Cards (J, Q, K) -// Invalid Cards + // Case 1: Ace (A) test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); - +// Suggestion: Group the remaining test data into these categories: +// Number Cards (2-10) +// Face Cards (J, Q, K) +// Invalid Cards // Case 2: Number cards (2-9) test(`Should return corresponding number when given a number card`, () => { expect(getCardValue("2♠")).toEqual(2); From 338d2f003fc51932f0ad821515ab54bec840eca7 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:26:14 +0100 Subject: [PATCH 42/52] delete line 7 Added a test case for the Ace card in Jest syntax. --- .../rewrite-tests-with-jest/3-get-card-value.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index 731c1da01b..888531c8fd 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -4,7 +4,6 @@ const getCardValue = require("../implement/3-get-card-value"); // 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); From e3db167a12a3aa01a1e82f09fde52dc0853b9d72 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:27:49 +0100 Subject: [PATCH 43/52] add line after line 10 Add suggestion to group test cases for better organization. --- .../rewrite-tests-with-jest/3-get-card-value.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index 888531c8fd..ecd34e1c3c 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -8,6 +8,7 @@ const getCardValue = require("../implement/3-get-card-value"); test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); + // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) From 11e3132e00cf3552058d8dce571e46e6f1aefca1 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:29:36 +0100 Subject: [PATCH 44/52] Clean up comments in card value test Removed unnecessary comments about Jest documentation. --- .../rewrite-tests-with-jest/3-get-card-value.test.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index ecd34e1c3c..82a8f15814 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -14,6 +14,9 @@ test(`Should return 11 when given an ace card`, () => { // Face Cards (J, Q, K) // Invalid Cards // Case 2: Number cards (2-9) +// 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 test(`Should return corresponding number when given a number card`, () => { expect(getCardValue("2♠")).toEqual(2); expect(getCardValue("3♠")).toEqual(3); @@ -55,6 +58,4 @@ test(`should throw an error with message "Invalid card format" when given invali expect(() => getCardValue("$$")).toThrow("Invalid card format"); expect(() => getCardValue("-5♣")).toThrow("Invalid card format"); }); -// 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 52c9e2e9526d265bc18bed52434982fbe3b607a6 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:31:15 +0100 Subject: [PATCH 45/52] Add implementation instructions for repeatStr Added implementation notes for repeatStr function. --- Sprint-3/2-practice-tdd/repeat-str.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index 3a3b81b65b..3c20ccee52 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -1,4 +1,7 @@ function repeatStr(str, num) { +// 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"; var result = ""; var i; if (num < 0) { From 7994451b4df73f4ed484d84ae200c0f24ef1a88f Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:33:08 +0100 Subject: [PATCH 46/52] add blank line 16 Added comments to categorize test data and provide guidance on error testing. --- .../rewrite-tests-with-jest/3-get-card-value.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js index 82a8f15814..5f43a43778 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js +++ b/Sprint-3/1-implement-and-rewrite-tests/rewrite-tests-with-jest/3-get-card-value.test.js @@ -13,6 +13,7 @@ test(`Should return 11 when given an ace card`, () => { // Number Cards (2-10) // Face Cards (J, Q, K) // Invalid Cards + // Case 2: Number cards (2-9) // To learn how to test whether a function throws an error as expected in Jest, // please refer to the Jest documentation: From 7bf6788b4fe2177709248bfde1e201e9a23727a1 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:34:08 +0100 Subject: [PATCH 47/52] Comment out return statement for '1st' in function Commented out the return statement for '1st' in the getOrdinalNumber function. --- Sprint-3/2-practice-tdd/get-ordinal-number.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Sprint-3/2-practice-tdd/get-ordinal-number.js b/Sprint-3/2-practice-tdd/get-ordinal-number.js index 56e599817b..3a38b9fc01 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.js @@ -1,4 +1,5 @@ function getOrdinalNumber(num) { + //return "1st"; if (num % 100 === 11) { return `${num}th`; } else if (num % 100 === 12) { From a8bbcc69776ad09f235015c11ecd780a5ad2ee62 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:35:28 +0100 Subject: [PATCH 48/52] Update comment to clarify implementation requirements --- Sprint-3/2-practice-tdd/repeat-str.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index 3c20ccee52..8e8a5c23f9 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -1,5 +1,5 @@ function repeatStr(str, num) { -// 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). + // 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"; var result = ""; From bf23461c88959b23d6805e52aad2084fd81b8fe5 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:36:15 +0100 Subject: [PATCH 49/52] Update comment to clarify implementation requirements --- Sprint-3/2-practice-tdd/repeat-str.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index 8e8a5c23f9..fb102627cb 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -1,5 +1,5 @@ function repeatStr(str, num) { - // 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). + // 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"; var result = ""; From 1a86e1f1bad3332a6c77ec81b38f0794fdf58cc1 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:36:36 +0100 Subject: [PATCH 50/52] Clarify repeatStr function implementation requirements Updated comments to clarify implementation requirements for repeatStr function. --- Sprint-3/2-practice-tdd/repeat-str.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index fb102627cb..32313d701c 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -1,5 +1,5 @@ function repeatStr(str, num) { - // 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). + // 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"; var result = ""; From 54d7a2740bd16863c113f57780076316c718a81e Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:45:08 +0100 Subject: [PATCH 51/52] Add comments to countChar function --- Sprint-3/2-practice-tdd/count.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sprint-3/2-practice-tdd/count.js b/Sprint-3/2-practice-tdd/count.js index e956721c1e..9e0239a4a0 100644 --- a/Sprint-3/2-practice-tdd/count.js +++ b/Sprint-3/2-practice-tdd/count.js @@ -1,4 +1,6 @@ function countChar(stringOfCharacters, findCharacter) { +// return 5 +//} let count = 0; for (let char of stringOfCharacters) { if (char === findCharacter) { From 33e84239a539838badc469b5221a11de8fcefc4c Mon Sep 17 00:00:00 2001 From: vmoratti Date: Fri, 17 Jul 2026 13:46:20 +0100 Subject: [PATCH 52/52] Update comment to clarify implementation requirements --- Sprint-3/2-practice-tdd/repeat-str.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index 32313d701c..fb102627cb 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -1,5 +1,5 @@ function repeatStr(str, num) { - // 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). + // 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"; var result = "";