From 32eef26d65755a1eff8dce3708694e9cf4817ab3 Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 13:48:30 +0000 Subject: [PATCH 01/30] implemented acute and obtuse angle identification in getAngleType function --- .../implement/1-get-angle-type.js | 6 +++--- 1 file changed, 3 insertions(+), 3 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 ca1dfe7f2..ea08ef95c 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 @@ -8,9 +8,9 @@ // Then, write the next test! :) Go through this process until all the cases are implemented function getAngleType(angle) { - if (angle === 90) { - return "Right angle"; - } + if (angle === 90) return "Right angle"; + if (angle < 90) return "Acute angle"; + if (angle > 90) && (angle < 180)) return "Obtuse angle"; // Run the tests, work out what Case 2 is testing, and implement the required code here. // Then keep going for the other cases, one at a time. } From 0709cbe66206dea7a7bfeae55db89e442ba0c448 Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 14:03:40 +0000 Subject: [PATCH 02/30] Implement straight angle identification in getAngleType function and add corresponding test case --- .../implement/1-get-angle-type.js | 3 +++ 1 file changed, 3 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 ea08ef95c..4f1dcb338 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 @@ -11,6 +11,7 @@ function getAngleType(angle) { if (angle === 90) return "Right angle"; if (angle < 90) return "Acute angle"; if (angle > 90) && (angle < 180)) return "Obtuse angle"; + if (angle === 180) return "Straight angle"; // Run the tests, work out what Case 2 is testing, and implement the required code here. // Then keep going for the other cases, one at a time. } @@ -56,6 +57,8 @@ const obtuse = getAngleType(120); // When the angle is exactly 180 degrees, // Then the function should return "Straight angle" // ====> write your test here, and then add a line to pass the test in the function above +const straight = getAngleType(180); +assertEquals(straight, "Straight angle"); // Case 5: Identify Reflex Angles: // When the angle is greater than 180 degrees and less than 360 degrees, From def56691c57f666b87c93981e591a15d1dab75b8 Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 14:05:49 +0000 Subject: [PATCH 03/30] fixed if statement for obtuse angle --- .../implement/1-get-angle-type.js | 3 ++- 1 file changed, 2 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 4f1dcb338..9a8d9e51f 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 @@ -10,7 +10,7 @@ function getAngleType(angle) { if (angle === 90) return "Right angle"; if (angle < 90) return "Acute angle"; - if (angle > 90) && (angle < 180)) return "Obtuse angle"; + if ((angle > 90) && (angle < 180)) return "Obtuse angle"; if (angle === 180) return "Straight angle"; // Run the tests, work out what Case 2 is testing, and implement the required code here. // Then keep going for the other cases, one at a time. @@ -51,6 +51,7 @@ assertEquals(acute, "Acute angle"); // When the angle is greater than 90 degrees and less than 180 degrees, // Then the function should return "Obtuse angle" const obtuse = getAngleType(120); +assertEquals(obtuse, "Obtuse angle"); // ====> write your test here, and then add a line to pass the test in the function above // Case 4: Identify Straight Angles: From 487694e6dddfabc18922ff6f891fe583d4400c49 Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 14:07:58 +0000 Subject: [PATCH 04/30] Implement reflex angle identification in getAngleType function and add corresponding test case --- .../implement/1-get-angle-type.js | 6 +++++- 1 file changed, 5 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 9a8d9e51f..fe2463942 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 @@ -12,6 +12,8 @@ function getAngleType(angle) { if (angle < 90) return "Acute angle"; if ((angle > 90) && (angle < 180)) return "Obtuse angle"; if (angle === 180) return "Straight angle"; + if ((angle > 180) && (angle < 360)) return "Reflex angle"; + // Run the tests, work out what Case 2 is testing, and implement the required code here. // Then keep going for the other cases, one at a time. } @@ -64,4 +66,6 @@ assertEquals(straight, "Straight angle"); // Case 5: Identify Reflex Angles: // When the angle is greater than 180 degrees and less than 360 degrees, // Then the function should return "Reflex angle" -// ====> write your test here, and then add a line to pass the test in the function above \ No newline at end of file +// ====> write your test here, and then add a line to pass the test in the function above +const reflex = getAngleType(270); +assertEquals(reflex, "Reflex angle"); \ No newline at end of file From 5fb6f956e667f00323f2d02de0fcbefc179929bc Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 14:10:37 +0000 Subject: [PATCH 05/30] fix: add missing assertions for negative and equal fraction checks --- .../implement/2-is-proper-fraction.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 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 a4739af77..7df83dfb4 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 @@ -8,15 +8,10 @@ // write one test at a time, and make it pass, build your solution up methodically function isProperFraction(numerator, denominator) { - if (numerator < denominator) { - return true; - } + if (numerator < denominator) return true; + else return false; } -// 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) { console.assert( @@ -47,6 +42,7 @@ assertEquals(improperFraction, false); // Explanation: The fraction -4/7 is a proper fraction because the absolute value of the numerator (4) is less than the denominator (7). The function should return true. const negativeFraction = isProperFraction(-4, 7); // ====> complete with your assertion +assertEquals(properFraction, true); // Equal Numerator and Denominator check: // Input: numerator = 3, denominator = 3 @@ -54,6 +50,7 @@ const negativeFraction = isProperFraction(-4, 7); // Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false. const equalFraction = isProperFraction(3, 3); // ====> complete with your assertion +assertEquals(equalFraction, false) // Stretch: // What other scenarios could you test for? From 876b8a1d7f2c056ccfa4ff3146c5d2dd360b2c1f Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 14:16:38 +0000 Subject: [PATCH 06/30] Implement card value retrieval for face cards and number cards in getCardValue function with comments explaining function and updated tests --- .../implement/3-get-card-value.js | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 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 266525d1b..475c1345c 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 @@ -8,15 +8,14 @@ // write one test at a time, and make it pass, build your solution up methodically // just make one change at a time -- don't rush -- programmers are deep and careful thinkers function getCardValue(card) { - if (rank === "A") { - return 11; - } + var rank = card.slice(0, -1); // get the rank of the card by removing the last character. (the suit is the last character) + if (rank === "A") return 11; // this checks for Aces + if (rank === "5") return 5; // this should check for the number 5 + if (rank === "J") return 10; // this checks for Jacks + if (rank === "Q") return 10; // this checks for Queens + if (rank === "K") return 10; // this checks for Kings + if (rank === "10") return 10; // this checks for Tens } - -// 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; - // You need to write assertions for your function to check it works in different cases // we're going to use this helper function to make our assertions easier to read // if the actual output matches the target output, the test will pass @@ -39,15 +38,20 @@ assertEquals(aceofSpades, 11); // When the function is called with such a card, // Then it should return the numeric value corresponding to the rank (e.g., "5" should return 5). const fiveofHearts = getCardValue("5♥"); +assertEquals(fiveofHearts, 5); // ====> write your test here, and then add a line to pass the test in the function above // Handle Face Cards (J, Q, K): // Given a card with a rank of "10," "J," "Q," or "K", // When the function is called with such a card, // Then it should return the value 10, as these cards are worth 10 points each in blackjack. +const jackOfDiamonds = getCardValue("J♦"); +const queenOfClubs = getCardValue("Q♣"); +const kingOfSpades = getCardValue("K♠"); +assertEquals(jackOfDiamonds, 10); +assertEquals(queenOfClubs, 10); +assertEquals(kingOfSpades, 10); -// Handle Ace (A): -// Given a card with a rank of "A", // When the function is called with an Ace, // Then it should, by default, assume the Ace is worth 11 points, which is a common rule in blackjack. From 801d5d8edd48dfe3f5f0580b5bcd1fd078de685c Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 14:17:12 +0000 Subject: [PATCH 07/30] Implement numerical value retrieval for cards 2-9 in getCardValue function and add corresponding test cases --- .../implement/3-get-card-value.js | 16 +++++++++++++++- 1 file changed, 15 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 475c1345c..63aa58f36 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 @@ -10,7 +10,14 @@ function getCardValue(card) { var rank = card.slice(0, -1); // get the rank of the card by removing the last character. (the suit is the last character) if (rank === "A") return 11; // this checks for Aces - if (rank === "5") return 5; // this should check for the number 5 + if (rank === "2") return 2; // this checks for the twos + if (rank === "3") return 3; // this checks for the threes + if (rank === "4") return 4; // this checks for the fours + if (rank === "5") return 5; // this should check for fives + if (rank === "6") return 6; // this checks for the sixes + if (rank === "7") return 7; // this checks for the sevens + if (rank === "8") return 8; // this checks for the eights + if (rank === "9") return 9; // this checks for the nines if (rank === "J") return 10; // this checks for Jacks if (rank === "Q") return 10; // this checks for Queens if (rank === "K") return 10; // this checks for Kings @@ -38,7 +45,13 @@ assertEquals(aceofSpades, 11); // When the function is called with such a card, // Then it should return the numeric value corresponding to the rank (e.g., "5" should return 5). const fiveofHearts = getCardValue("5♥"); +const sixofDiamonds = getCardValue("6♦"); +const sevenofClubs = getCardValue("7♣"); +const eightofSpades = getCardValue("8♠"); assertEquals(fiveofHearts, 5); +assertEquals(sixofDiamonds, 6); +assertEquals(sevenofClubs, 7); +assertEquals(eightofSpades, 8); // ====> write your test here, and then add a line to pass the test in the function above // Handle Face Cards (J, Q, K): @@ -59,3 +72,4 @@ assertEquals(kingOfSpades, 10); // Given a card with an invalid rank (neither a number nor a recognized face card), // When the function is called with such a card, // Then it should throw an error indicating "Invalid card rank." + From 7e6166b6ade628f49248940bf61d32be8dee5554 Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 14:18:17 +0000 Subject: [PATCH 08/30] Enhance getCardValue function comments and add error handling for invalid card ranks --- .../implement/3-get-card-value.js | 13 +++++++++++-- 1 file changed, 11 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 63aa58f36..b588ac3be 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 @@ -10,6 +10,7 @@ function getCardValue(card) { var rank = card.slice(0, -1); // get the rank of the card by removing the last character. (the suit is the last character) if (rank === "A") return 11; // this checks for Aces + // Handle Number Cards (2-9) if (rank === "2") return 2; // this checks for the twos if (rank === "3") return 3; // this checks for the threes if (rank === "4") return 4; // this checks for the fours @@ -18,10 +19,13 @@ function getCardValue(card) { if (rank === "7") return 7; // this checks for the sevens if (rank === "8") return 8; // this checks for the eights if (rank === "9") return 9; // this checks for the nines + // Handle Face Cards (J, Q, K) And 10's if (rank === "J") return 10; // this checks for Jacks if (rank === "Q") return 10; // this checks for Queens if (rank === "K") return 10; // this checks for Kings if (rank === "10") return 10; // this checks for Tens + // if none of the above its an invalid card and throw an error + throw new Error("Invalid card rank."); // this will throw an error if the card is not a valid rank } // You need to write assertions for your function to check it works in different cases // we're going to use this helper function to make our assertions easier to read @@ -44,6 +48,7 @@ assertEquals(aceofSpades, 11); // Given a card with a rank between "2" and "9", // When the function is called with such a card, // Then it should return the numeric value corresponding to the rank (e.g., "5" should return 5). +// ====> write your test here, and then add a line to pass the test in the function above const fiveofHearts = getCardValue("5♥"); const sixofDiamonds = getCardValue("6♦"); const sevenofClubs = getCardValue("7♣"); @@ -52,7 +57,6 @@ assertEquals(fiveofHearts, 5); assertEquals(sixofDiamonds, 6); assertEquals(sevenofClubs, 7); assertEquals(eightofSpades, 8); -// ====> write your test here, and then add a line to pass the test in the function above // Handle Face Cards (J, Q, K): // Given a card with a rank of "10," "J," "Q," or "K", @@ -72,4 +76,9 @@ assertEquals(kingOfSpades, 10); // Given a card with an invalid rank (neither a number nor a recognized face card), // When the function is called with such a card, // Then it should throw an error indicating "Invalid card rank." - +try { + getCardValue("z♠"); // this should throw an error of "Invalid card rank." + console.log("Test failed: Expected an error for invalid card rank."); +} catch(error){ + assertEquals(error.meessage, "Invalid card rank."); +} \ No newline at end of file From dbf085fb4022426eb7c65437a8cf6e19ca9465df Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 14:18:48 +0000 Subject: [PATCH 09/30] Fix typo in error message assertion for invalid card rank in getCardValue function --- .../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 b588ac3be..a4dc4ede8 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 @@ -80,5 +80,5 @@ try { getCardValue("z♠"); // this should throw an error of "Invalid card rank." console.log("Test failed: Expected an error for invalid card rank."); } catch(error){ - assertEquals(error.meessage, "Invalid card rank."); + assertEquals(error.message, "Invalid card rank."); } \ No newline at end of file From a09a9927e926bf7a3cbee6e4bedc64b42bca64fc Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 14:24:02 +0000 Subject: [PATCH 10/30] refactor: implement character counting logic in countChar function --- Sprint-3/2-practice-tdd/count.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Sprint-3/2-practice-tdd/count.js b/Sprint-3/2-practice-tdd/count.js index 95b6ebb7d..f18e4ebd1 100644 --- a/Sprint-3/2-practice-tdd/count.js +++ b/Sprint-3/2-practice-tdd/count.js @@ -1,5 +1,18 @@ function countChar(stringOfCharacters, findCharacter) { - return 5 + // start a count of 0 + let count = 0; + + // check each of the characters in the string one by one. + for (let i = 0; i < stringOfCharacters.length; i++) { + // checks if the current characters matches the one were looking for in the string. + if (stringOfCharacters[i] === findCharacter) + // if it does, we increment the count by 1. + count = count + 1; +} + + return count; } +console.log(countChar("aaaaa", "a")); // 5 +console.log(countChar("hello", "l")); // 2 -module.exports = countChar; +module.exports = countChar; \ No newline at end of file From 5f2aa2c6be1623f14bf3f380f64ede64860fd244 Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 14:27:10 +0000 Subject: [PATCH 11/30] add test for handling no occurrences of a character in countChar function --- 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 42baf4b4b..9f0bf3d7d 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 the case-sensitive str, // When the function is called with these inputs, // Then it should return 0, indicating that no occurrences of the char were found in the case-sensitive str. + +test("should return 0 for no occurrences of a character", () => { + const str = "example"; + const char = "z"; + const count = countChar(str, char); + expect(count).toEqual(0); +}); \ No newline at end of file From 22f8e4a652b07aca100ba9c717c33df2345ec486 Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 14:35:18 +0000 Subject: [PATCH 12/30] implemented how special ordinal number cases like 11,12,13 are handled by making sure they always end in "th" --- Sprint-3/2-practice-tdd/get-ordinal-number.js | 9 ++++++++- 1 file changed, 8 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 f95d71db1..93eb84945 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.js @@ -1,5 +1,12 @@ function getOrdinalNumber(num) { - return "1st"; + const lastTwoDigits = num % 100; // gets the last two digits of the number because some like 11, 12, 13 are special cases. + const lastDigit= num % 10; // gets the last digit to decide if its going to be "St, Nd, Rd" + + // handles special cases like "11,12,13" to always end in the "Th" + if (lastTwoDigits === 11 || lastTwoDigits === 12 || lastTwoDigits === 13){ + return num + "St"; +} + } module.exports = getOrdinalNumber; From f3f8b4707ccab78acae8f7bf41aa2aadf196182f Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 14:37:45 +0000 Subject: [PATCH 13/30] refactor: implement getOrdinalNumber function to return correct ordinal suffixes --- Sprint-3/2-practice-tdd/get-ordinal-number.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Sprint-3/2-practice-tdd/get-ordinal-number.js b/Sprint-3/2-practice-tdd/get-ordinal-number.js index 93eb84945..ac30abf48 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.js @@ -6,7 +6,21 @@ function getOrdinalNumber(num) { if (lastTwoDigits === 11 || lastTwoDigits === 12 || lastTwoDigits === 13){ return num + "St"; } + // will return "St" if the number ends in 1. + if (lastDigit === 1){ + return num + "st"; + } +// will return "Nd" if the number ends in 2. + if (lastDigit === 2){ + return num + "nd"; + } +// will return "Rd" if the number ends in 3. + if (lastDigit === 3){ + return num + "rd"; + } +// will return all numbers that end in 4, 5, 6, 7, 8, 9 with "Th". + return num + "th"; } module.exports = getOrdinalNumber; From f08ec155572948edfbbad512b1666c2900df642e Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 14:41:36 +0000 Subject: [PATCH 14/30] implented tests for ordinal numbers 2nd and 3rd --- .../2-practice-tdd/get-ordinal-number.test.js | 15 +++++++++++++++ 1 file changed, 15 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 dfe4b6091..307ac0a58 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.test.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.test.js @@ -11,3 +11,18 @@ const getOrdinalNumber = require("./get-ordinal-number"); test("should return '1st' for 1", () => { expect(getOrdinalNumber(1)).toEqual("1st"); }); +// Case 2: Identify the ordinal number for 2 +// When the number is 2, +// The function should then return "2nd". + +test("Should return `2nd` for 2", () => { + expect(getOrdinalNumber(2)).toEqual("2nd"); +}); + +// Case 3: Identify the ordinal number for 3 +// When the number is 3, +// The Function should the return "3rd" + +test("Should return `3rd` for 3", () => { + expect(getOrdinalNumber(3)).toEqual("3rd"); +}); \ No newline at end of file From 234e8b6631a4c0ee3a1e331dc619607defd79a26 Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 14:42:35 +0000 Subject: [PATCH 15/30] test: update test descriptions for ordinal numbers and implemented a test for special ordinal numbers --- 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 307ac0a58..edcef9490 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.test.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.test.js @@ -25,4 +25,16 @@ test("Should return `2nd` for 2", () => { test("Should return `3rd` for 3", () => { expect(getOrdinalNumber(3)).toEqual("3rd"); +}); +// Case 4: identify the special ordinal numbers for 11, 12, 13 +// When the number is 11, 12, 13, +// The function should return "11th, 12th, 13th" + +test ("should return `11th, 12th, 13th` for special ordinal numbers ending on these", () => { + expect(getOrdinalNumber(11)).toEqual("11th"); + expect(getOrdinalNumber(12)).toEqual("12th"); + expect(getOrdinalNumber(13)).toEqual("13th"); + expect(getOrdinalNumber(111)).toEqual("111th"); + expect(getOrdinalNumber(112)).toEqual("112th"); + expect(getOrdinalNumber(113)).toEqual("113th"); }); \ No newline at end of file From 6a021e32c2d432a2a756d74b66558d44a967bdf7 Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 15:02:22 +0000 Subject: [PATCH 16/30] implemented repeat function with error handling and edge cases with comments detailing. --- Sprint-3/2-practice-tdd/repeat-str.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index 3838c7b00..a3262d8f9 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -1,5 +1,19 @@ -function repeatStr() { - return "hellohellohello"; +function repeatStr(str, count) { + // check if "count" is a negative number if so will throw new error + if (count < 0) { + throw new error("Count must be a positive number"); + + //check if the is equal to zero + if (count === 0){ + return ""; // returns empty string if count is equal to zero + } + //check if the count is equals 1. + if (count === 1) { + //returns just the string as its not needed to be repeated + return str; + } + return str.repeat(count); // if the count is above two it repeat "count" number of times. +} } module.exports = repeatStr; From 74552537b5d1dda6850f2a4bcf34409ed1707b29 Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 15:03:29 +0000 Subject: [PATCH 17/30] test: add test case for returning original string when count is 1 --- Sprint-3/2-practice-tdd/repeat-str.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-3/2-practice-tdd/repeat-str.test.js b/Sprint-3/2-practice-tdd/repeat-str.test.js index fc59d019e..9b530446a 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.test.js +++ b/Sprint-3/2-practice-tdd/repeat-str.test.js @@ -20,6 +20,12 @@ 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, ensuring that a count of 1 results in no repetition. +test("should return the original string when count is 1", () => { + const str = "hello"; + const count = 1; + const repeatedStr = repeat(str, count); + expect(repeatedStr).toEqual("hello"); +}); // case: Handle Count of 0: // Given a target string str and a count equal to 0, From 5e1196facbd09c37b3c6c248d3ba7c6df7eada1c Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 15:04:02 +0000 Subject: [PATCH 18/30] test: add test case for returning original string when count is 0 --- Sprint-3/2-practice-tdd/repeat-str.test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Sprint-3/2-practice-tdd/repeat-str.test.js b/Sprint-3/2-practice-tdd/repeat-str.test.js index 9b530446a..d5fb377c2 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.test.js +++ b/Sprint-3/2-practice-tdd/repeat-str.test.js @@ -31,6 +31,12 @@ test("should return the original string when count is 1", () => { // 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, ensuring that a count of 0 results in an empty output. +test("should give a empty string when count is 0", () => { + const str = "hello"; + const count = 0; + const repeatedStr = repeat(str, count); + expect(repeatedStr).toEqual(""); +}) // case: Negative Count: // Given a target string str and a negative integer count, From cc80d7e9e45305212cd7201443ee24214f2c1469 Mon Sep 17 00:00:00 2001 From: Declan W Date: Sat, 1 Nov 2025 15:04:37 +0000 Subject: [PATCH 19/30] test: add test case for returning original string when count is negative --- Sprint-3/2-practice-tdd/repeat-str.test.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Sprint-3/2-practice-tdd/repeat-str.test.js b/Sprint-3/2-practice-tdd/repeat-str.test.js index d5fb377c2..bf461b026 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.test.js +++ b/Sprint-3/2-practice-tdd/repeat-str.test.js @@ -42,3 +42,8 @@ test("should give a empty string when count is 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 or return an appropriate error message, as negative counts are not valid. +test("should throw an error when count is negative", () => { + const str = "hello" + const count = -1; + expect(() => repeat(str,count)).toThrow("Count must be a positive number"); +}); \ No newline at end of file From ca08ca9335dbf290833dd1c3a72c6b00da7ab6fb Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Sat, 15 Nov 2025 10:49:42 +0000 Subject: [PATCH 20/30] implemented the cases of jest tests for each of the angles --- .../rewrite-tests-with-jest/1-get-angle-type.test.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 4a92a3e82..2f58e3121 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 @@ -12,15 +12,27 @@ test("should identify right angle (90°)", () => { // Case 2: Identify Acute Angles: // When the angle is less than 90 degrees, // Then the function should return "Acute angle" +test("should identify as Acute angle (< 90°)", () => { + expect(getAngleType(75)).toEqual("Acute angle"); +}); // Case 3: Identify Obtuse Angles: // When the angle is greater than 90 degrees and less than 180 degrees, // Then the function should return "Obtuse angle" +test("should identify as Obtuse angle (> 90° and < 180°)", () => { + expect(getAngleType(155)).toEqual("Obtuse angle"); +}); // Case 4: Identify Straight Angles: // When the angle is exactly 180 degrees, // Then the function should return "Straight angle" +test("should identify as straight angle (180°)", () => { + expect(getAngleType(180)).toEqual("Straight angle"); +}); // Case 5: Identify Reflex Angles: // When the angle is greater than 180 degrees and less than 360 degrees, // Then the function should return "Reflex angle" +test("should identify as Reflex angle (> 180° and < 360°)", () => { + expect(getAngleType(270)).toEqual("Reflex angle"); +}); From 7dc44ecc11130a3bc41efd9d3bca4b630b7adad9 Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Sat, 15 Nov 2025 11:24:10 +0000 Subject: [PATCH 21/30] fix: update isProperFraction function logic and add missing assertion --- .../implement/2-is-proper-fraction.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 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 7df83dfb4..322155cfa 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 @@ -8,8 +8,10 @@ // write one test at a time, and make it pass, build your solution up methodically function isProperFraction(numerator, denominator) { - if (numerator < denominator) return true; - else return false; + if (denominator === 0) { + throw new Error(); + } + return Math.abs(numerator) < Math.abs(denominator); } // here's our helper again @@ -50,7 +52,7 @@ assertEquals(properFraction, true); // Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false. const equalFraction = isProperFraction(3, 3); // ====> complete with your assertion -assertEquals(equalFraction, false) +assertEquals(equalFraction, false); // Stretch: // What other scenarios could you test for? From 5e720c84021311f89306ab9d7a67b12b9fae4728 Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Sat, 15 Nov 2025 11:31:43 +0000 Subject: [PATCH 22/30] fix: update isProperFraction to return false for zero denominator instead of throwing an error --- .../implement/2-is-proper-fraction.js | 4 +--- 1 file changed, 1 insertion(+), 3 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 322155cfa..dba7e55bd 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 @@ -8,9 +8,7 @@ // write one test at a time, and make it pass, build your solution up methodically function isProperFraction(numerator, denominator) { - if (denominator === 0) { - throw new Error(); - } + if (denominator === 0) return false; // avoid division by zero return Math.abs(numerator) < Math.abs(denominator); } From 252bfb978c9db8cd43b9e021c12b2c125c2ba9eb Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Sat, 15 Nov 2025 11:39:50 +0000 Subject: [PATCH 23/30] added "module.exports" so jest can find the function --- .../implement/2-is-proper-fraction.js | 2 ++ 1 file changed, 2 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 dba7e55bd..888f8bd16 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 @@ -54,3 +54,5 @@ assertEquals(equalFraction, false); // Stretch: // What other scenarios could you test for? + +module.exports = isProperFraction; \ No newline at end of file From 3b7e322addcd040ccf4d566638eee15e1226f935 Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Sat, 15 Nov 2025 11:45:00 +0000 Subject: [PATCH 24/30] implmented jest tests for each of the cases --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 9 +++++++++ 1 file changed, 9 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 caf08d15b..ec7ea01e6 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 @@ -7,7 +7,16 @@ test("should return true for a proper fraction", () => { }); // Case 2: Identify Improper Fractions: +test("should return false for an improper fraction", () => { + expect(isProperFraction(5, 2)).toEqual(false); +}); // Case 3: Identify Negative Fractions: +test("should return true for a negative proper fraction", () => { + expect(isproperFraction(-4, 7)).toEqual(true); +}); // Case 4: Identify Equal Numerator and Denominator: +test ("should return false when numerator equals denominator", () => { + expect(isProperFraction(0, 5)).toEqual(false); +}); \ No newline at end of file From 809e11b516752d4f93c148c5c9cd11a6a679ad92 Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Sat, 15 Nov 2025 11:46:46 +0000 Subject: [PATCH 25/30] fixed equal numerator and denominator jest test --- .../rewrite-tests-with-jest/2-is-proper-fraction.test.js | 2 +- 1 file changed, 1 insertion(+), 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 ec7ea01e6..272f89841 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 @@ -18,5 +18,5 @@ test("should return true for a negative proper fraction", () => { // Case 4: Identify Equal Numerator and Denominator: test ("should return false when numerator equals denominator", () => { - expect(isProperFraction(0, 5)).toEqual(false); + expect(isProperFraction(3, 3)).toEqual(false); }); \ No newline at end of file From 0b2a485abae4c93026d0bd93ee03a7abf86e8c3e Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Sat, 15 Nov 2025 11:52:32 +0000 Subject: [PATCH 26/30] added module.exports --- .../implement/3-get-card-value.js | 3 ++- .../3-get-card-value.test.js | 24 ++++++++++++++++++- 2 files changed, 25 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 a4dc4ede8..c5fb5a6da 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 @@ -81,4 +81,5 @@ try { console.log("Test failed: Expected an error for invalid card rank."); } catch(error){ assertEquals(error.message, "Invalid card rank."); -} \ No newline at end of file +} +module.exports = getCardValue; \ No newline at end of file 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 04418ff72..b2fa048f3 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,7 +7,29 @@ test("should return 11 for Ace of Spades", () => { expect(aceofSpades).toEqual(11); }); -// Case 2: Handle Number Cards (2-10): +test("should return the correct value for number cards between 2 and 9", () => { + 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); + expect(getCardValue("10♥")).toEqual(10); +}); // Case 3: Handle Face Cards (J, Q, K): +test("should return 10 for face cards (J, Q, K)", () => { + expect(getCardValue("J♠")).toEqual(10); + expect(getCardValue("Q♦")).toEqual(10); + expect(getCardValue("K♣")).toEqual(10); +}); // Case 4: Handle Ace (A): +test("should return 11 for Aces", () => { + expect(getCardValue("A♠")).toEqual(11); +}); // Case 5: Handle Invalid Cards: +test("should throw an error for invalid card ranks", () => { + expect(() => getCardValue("X♠")).toThrow("Invalid card rank."); + expect(() => getCardValue("1♠")).toThrow("Invalid card rank."); +}); From 377b7dbde8f5b53790f6ec459509ed85a2022f44 Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Sat, 15 Nov 2025 12:09:16 +0000 Subject: [PATCH 27/30] fix: clean up formatting and ensure consistent error handling in getCardValue function --- .../implement/3-get-card-value.js | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 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 c5fb5a6da..841e0e6a3 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 @@ -8,24 +8,24 @@ // write one test at a time, and make it pass, build your solution up methodically // just make one change at a time -- don't rush -- programmers are deep and careful thinkers function getCardValue(card) { - var rank = card.slice(0, -1); // get the rank of the card by removing the last character. (the suit is the last character) - if (rank === "A") return 11; // this checks for Aces - // Handle Number Cards (2-9) - if (rank === "2") return 2; // this checks for the twos - if (rank === "3") return 3; // this checks for the threes - if (rank === "4") return 4; // this checks for the fours - if (rank === "5") return 5; // this should check for fives - if (rank === "6") return 6; // this checks for the sixes - if (rank === "7") return 7; // this checks for the sevens - if (rank === "8") return 8; // this checks for the eights - if (rank === "9") return 9; // this checks for the nines - // Handle Face Cards (J, Q, K) And 10's - if (rank === "J") return 10; // this checks for Jacks - if (rank === "Q") return 10; // this checks for Queens - if (rank === "K") return 10; // this checks for Kings - if (rank === "10") return 10; // this checks for Tens - // if none of the above its an invalid card and throw an error - throw new Error("Invalid card rank."); // this will throw an error if the card is not a valid rank + var rank = card.slice(0, -1); // get the rank of the card by removing the last character. (the suit is the last character) + if (rank === "A") return 11; // this checks for Aces + // Handle Number Cards (2-9) + if (rank === "2") return 2; // this checks for the twos + if (rank === "3") return 3; // this checks for the threes + if (rank === "4") return 4; // this checks for the fours + if (rank === "5") return 5; // this should check for fives + if (rank === "6") return 6; // this checks for the sixes + if (rank === "7") return 7; // this checks for the sevens + if (rank === "8") return 8; // this checks for the eights + if (rank === "9") return 9; // this checks for the nines + // Handle Face Cards (J, Q, K) And 10's + if (rank === "J") return 10; // this checks for Jacks + if (rank === "Q") return 10; // this checks for Queens + if (rank === "K") return 10; // this checks for Kings + if (rank === "10") return 10; // this checks for Tens + // if none of the above its an invalid card and throw an error + throw new Error("Invalid card rank."); // this will throw an error if the card is not a valid rank } // You need to write assertions for your function to check it works in different cases // we're going to use this helper function to make our assertions easier to read @@ -64,7 +64,7 @@ assertEquals(eightofSpades, 8); // Then it should return the value 10, as these cards are worth 10 points each in blackjack. const jackOfDiamonds = getCardValue("J♦"); const queenOfClubs = getCardValue("Q♣"); -const kingOfSpades = getCardValue("K♠"); +const kingOfSpades = getCardValue("K♠"); assertEquals(jackOfDiamonds, 10); assertEquals(queenOfClubs, 10); assertEquals(kingOfSpades, 10); @@ -79,7 +79,7 @@ assertEquals(kingOfSpades, 10); try { getCardValue("z♠"); // this should throw an error of "Invalid card rank." console.log("Test failed: Expected an error for invalid card rank."); -} catch(error){ +} catch (error) { assertEquals(error.message, "Invalid card rank."); } -module.exports = getCardValue; \ No newline at end of file +module.exports = getCardValue; From 096d45cfeaf27f83452d56cbc5ceba26c0a1e609 Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Sat, 15 Nov 2025 12:17:56 +0000 Subject: [PATCH 28/30] fix: correct ordinal suffix for special cases in getOrdinalNumber function --- Sprint-3/2-practice-tdd/get-ordinal-number.js | 2 +- 1 file changed, 1 insertion(+), 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 ac30abf48..a6ba0d68b 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.js @@ -4,7 +4,7 @@ function getOrdinalNumber(num) { // handles special cases like "11,12,13" to always end in the "Th" if (lastTwoDigits === 11 || lastTwoDigits === 12 || lastTwoDigits === 13){ - return num + "St"; + return num + "th"; } // will return "St" if the number ends in 1. if (lastDigit === 1){ From 1200ba77376123b35ae874a39eefb8d184dee658 Mon Sep 17 00:00:00 2001 From: Declan Williams Date: Sat, 15 Nov 2025 12:26:13 +0000 Subject: [PATCH 29/30] fix: enhance tests for getOrdinalNumber function to cover additional cases and improve formatting --- .../2-practice-tdd/get-ordinal-number.test.js | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) 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 edcef9490..a5114020c 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.test.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.test.js @@ -10,13 +10,17 @@ const getOrdinalNumber = require("./get-ordinal-number"); test("should return '1st' for 1", () => { expect(getOrdinalNumber(1)).toEqual("1st"); + expect(getOrdinalNumber(21)).toEqual("21st") + expect(getOrdinalNumber(141)).toEqual("141st") }); // Case 2: Identify the ordinal number for 2 // When the number is 2, // The function should then return "2nd". -test("Should return `2nd` for 2", () => { - expect(getOrdinalNumber(2)).toEqual("2nd"); +test("append 'nd' to numbers ending in 2, except those ending in 12", () => { + expect(getOrdinalNumber(2)).toEqual("2nd"); + expect(getOrdinalNumber(22)).toEqual("22nd"); + expect(getOrdinalNumber(132)).toEqual("132nd"); }); // Case 3: Identify the ordinal number for 3 @@ -24,17 +28,19 @@ test("Should return `2nd` for 2", () => { // The Function should the return "3rd" test("Should return `3rd` for 3", () => { - expect(getOrdinalNumber(3)).toEqual("3rd"); + expect(getOrdinalNumber(3)).toEqual("3rd"); + expect(getOrdinalNumber(23)).toEqual("23rd"); + expect(getOrdinalNumber(133)).toEqual("133rd"); }); -// Case 4: identify the special ordinal numbers for 11, 12, 13 +// Case 4: identify the special ordinal numbers for 11, 12, 13 // When the number is 11, 12, 13, // The function should return "11th, 12th, 13th" -test ("should return `11th, 12th, 13th` for special ordinal numbers ending on these", () => { - expect(getOrdinalNumber(11)).toEqual("11th"); - expect(getOrdinalNumber(12)).toEqual("12th"); - expect(getOrdinalNumber(13)).toEqual("13th"); - expect(getOrdinalNumber(111)).toEqual("111th"); - expect(getOrdinalNumber(112)).toEqual("112th"); - expect(getOrdinalNumber(113)).toEqual("113th"); -}); \ No newline at end of file +test("should return `11th, 12th, 13th` for special ordinal numbers ending on these", () => { + expect(getOrdinalNumber(11)).toEqual("11th"); + expect(getOrdinalNumber(12)).toEqual("12th"); + expect(getOrdinalNumber(13)).toEqual("13th"); + expect(getOrdinalNumber(111)).toEqual("111th"); + expect(getOrdinalNumber(112)).toEqual("112th"); + expect(getOrdinalNumber(113)).toEqual("113th"); +}); From 014b90eac1c66b7ded6db9bdc48631c171e07b0e Mon Sep 17 00:00:00 2001 From: Declan W Date: Wed, 19 Nov 2025 12:50:56 +0000 Subject: [PATCH 30/30] Enhance tests for proper fraction validation Added test cases for negative improper fractions. --- .../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 272f89841..f62baa0a2 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 @@ -19,4 +19,9 @@ test("should return true for a negative proper fraction", () => { // Case 4: Identify Equal Numerator and Denominator: test ("should return false when numerator equals denominator", () => { expect(isProperFraction(3, 3)).toEqual(false); -}); \ No newline at end of file +}); + +// Case 5: Identify Negative Improper Fractions: +test("should return false for a negative improper fraction", () => { + expect(isProperFraction(-4, 4)).toEqual(false); + expect(isProperFraction(10, -3)).toEqual(false);