From 0ef19ecd0dbfa1b78a38e06e58a3d32a454d89ba Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Mon, 22 Jun 2026 13:05:35 +0100 Subject: [PATCH 1/7] written tests to check whether a given angle matches the expected output --- .../implement/1-get-angle-type.js | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js b/Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js index 9e05a871e2..0110475245 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,13 +15,27 @@ // execute the code to ensure all tests pass. function getAngleType(angle) { - // TODO: Implement this function + if (angle > 0 && angle < 90) { + return "Acute angle"; + } + if (angle === 90) { + return "Right angle"; + } + if (angle > 90 && angle < 180) { + return "Obtuse angle"; + } + if (angle === 180) { + return "Straight angle"; + } + if (angle > 180 && angle < 360) { + return "Reflex angle"; + } + return "Invalid angle"; } // The line below allows us to load the getAngleType function into tests in other files. // This will be useful in the "rewrite tests with jest" step. module.exports = getAngleType; - // This helper function is written to make our assertions easier to read. // If the actual output matches the target output, the test will pass function assertEquals(actualOutput, targetOutput) { @@ -33,5 +47,15 @@ function assertEquals(actualOutput, targetOutput) { // TODO: Write tests to cover all cases, including boundary and invalid cases. // Example: Identify Right Angles +const acute = getAngleType(45); +assertEquals(acute, "Acute angle"); const right = getAngleType(90); assertEquals(right, "Right angle"); +const obtuse = getAngleType(135); +assertEquals(obtuse, "Obtuse angle"); +const straight = getAngleType(180); +assertEquals(straight, "Straight angle"); +const reflex = getAngleType(270); +assertEquals(reflex, "Reflex angle"); +const invalidAngle = getAngleType(-10); +assertEquals(invalidAngle, "Invalid angle"); From df94ea49dde79147e734a3340490d400fc72bad3 Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Sat, 27 Jun 2026 01:59:49 +0100 Subject: [PATCH 2/7] written jest test scripts for all the three functions --- .../implement/2-is-proper-fraction.js | 30 +++++++- .../implement/3-get-card-value.js | 70 ++++++++++++++++++- .../1-get-angle-type.test.js | 26 +++++++ .../2-is-proper-fraction.test.js | 35 +++++++++- .../3-get-card-value.test.js | 33 ++++++++- 5 files changed, 189 insertions(+), 5 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js b/Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js index 970cb9b641..50858ea196 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,16 @@ // execute the code to ensure all tests pass. function isProperFraction(numerator, denominator) { - // TODO: Implement this function + if (numerator === 0) { + return false; + } + if (denominator === 0) { + return false; + } + if (Number.isNaN(numerator) || Number.isNaN(denominator)) { + return false; + } + return Math.abs(numerator) < Math.abs(denominator); } // The line below allows us to load the isProperFraction function into tests in other files. @@ -25,6 +34,25 @@ function assertEquals(actualOutput, targetOutput) { `Expected ${actualOutput} to equal ${targetOutput}` ); } +// Proper fractions +assertEquals(isProperFraction(1, 2), true); +assertEquals(isProperFraction(3, 4), true); +assertEquals(isProperFraction(-1, 5), true); +assertEquals(isProperFraction(1, -5), true); + +// Improper fractions +assertEquals(isProperFraction(5, 3), false); +assertEquals(isProperFraction(10, 10), false); +assertEquals(isProperFraction(-7, 3), false); + +// Zero cases +assertEquals(isProperFraction(0, 5), false); +assertEquals(isProperFraction(3, 0), false); + +// NaN cases +assertEquals(isProperFraction(NaN, 5), false); +assertEquals(isProperFraction(3, NaN), false); +assertEquals(isProperFraction(NaN, NaN), false); // TODO: Write tests to cover all cases. // What combinations of numerators and denominators should you test? 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..83d4459c36 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,7 +22,34 @@ // execute the code to ensure all tests pass. function getCardValue(card) { - // TODO: Implement this function + const ranks = [ + "A", + "2", + "3", + "4", + "5", + "6", + "7", + "8", + "9", + "10", + "J", + "Q", + "K", + ]; + const suits = ["♠", "♥", "♦", "♣"]; + + let rank = card.slice(0, -1); // extracting the rank from the input + let suit = card.slice(-1); // extracting the suit from the input + if (!suits.includes(suit)) { + throw new Error("Invalid suit"); + } + if (!ranks.includes(rank)) { + throw new Error("Invalid rank"); + } + if (rank === "A") return 11; + if (["J", "Q", "K"].includes(rank)) return 10; + return Number(rank); } // The line below allows us to load the getCardValue function into tests in other files. @@ -39,7 +66,19 @@ function assertEquals(actualOutput, targetOutput) { // TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. // Examples: -assertEquals(getCardValue("9♠"), 9); +assertEquals(getCardValue("J♥"), 10); +// Number cards +assertEquals(getCardValue("2♠"), 2); +assertEquals(getCardValue("9♥"), 9); +assertEquals(getCardValue("10♦"), 10); + +// Face cards +assertEquals(getCardValue("J♣"), 10); +assertEquals(getCardValue("Q♦"), 10); +assertEquals(getCardValue("K♥"), 10); + +// Ace +assertEquals(getCardValue("A♠"), 11); // Handling invalid cards try { @@ -52,3 +91,30 @@ try { } // What other invalid card cases can you think of? +try { + getCardValue(""); + console.error("Error NOT thrown for empty string"); +} catch (e) { + console.log("Error thrown for empty string 🎉"); +} + +try { + getCardValue("1♠"); + console.error("Error NOT thrown for invalid rank"); +} catch (e) { + console.log("Error thrown for invalid rank 🎉"); +} + +try { + getCardValue("A"); + console.error("Error NOT thrown for missing suit"); +} catch (e) { + console.log("Error thrown for missing suit 🎉"); +} + +try { + getCardValue("A?"); + console.error("Error NOT thrown for invalid suit"); +} catch (e) { + console.log("Error thrown for invalid suit 🎉"); +} 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..92afb0d951 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,33 @@ test(`should return "Acute angle" when (0 < angle < 90)`, () => { }); // Case 2: Right angle +test(`should return "Right angle" when angle === 90`, () => { + 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"); + expect(getAngleType(120)).toEqual("Obtuse angle"); + expect(getAngleType(179)).toEqual("Obtuse angle"); +}); + // Case 4: Straight angle +test(`should return "Straight angle" when angle === 180`, () => { + expect(getAngleType(180)).toEqual("Straight angle"); +}); + // Case 5: Reflex angles +test(`should return "Reflex angle" when (180 < angle < 360)`, () => { + expect(getAngleType(181)).toEqual("Reflex angle"); + expect(getAngleType(250)).toEqual("Reflex angle"); + expect(getAngleType(359)).toEqual("Reflex angle"); +}); + // Case 6: Invalid angles +test(`should return "Invalid angle" for angles outside 0–360`, () => { + expect(getAngleType(0)).toEqual("Invalid angle"); // boundary + expect(getAngleType(360)).toEqual("Invalid angle"); // boundary + expect(getAngleType(-10)).toEqual("Invalid angle"); + expect(getAngleType(400)).toEqual("Invalid angle"); +}); 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..3c45c8642c 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,40 @@ 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 false when numerator is zero`, () => { + expect(isProperFraction(0, 1)).toEqual(false); +}); +// Proper functions with absolute numerator < absolute denominator +test(`should return true for proper positive fractions`, () => { + expect(isProperFraction(1, 2)).toEqual(true); + expect(isProperFraction(3, 4)).toEqual(true); +}); +// Proper functions with negative numbers +test(`should return true for proper negative fractions`, () => { + expect(isProperFraction(-1, 2)).toEqual(true); + expect(isProperFraction(1, -3)).toEqual(true); + expect(isProperFraction(-2, -5)).toEqual(true); +}); +// Improper functions with absolute numerator >= absolute denominator +test(`should return false for improper fractions`, () => { + expect(isProperFraction(5, 3)).toEqual(false); + expect(isProperFraction(10, 10)).toEqual(false); + expect(isProperFraction(-7, 3)).toEqual(false); +}); +// Special cases: numerator or denominator is NAN +test(`should return false when numerator or denominator is NaN`, () => { + expect(isProperFraction(NaN, 5)).toEqual(false); + expect(isProperFraction(3, NaN)).toEqual(false); + expect(isProperFraction(NaN, NaN)).toEqual(false); +}); +// Special cases: non-number strings +test(`should return false for non-numeric strings`, () => { + expect(isProperFraction("a", 5)).toEqual(false); + expect(isProperFraction(3, "b")).toEqual(false); +}); 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..5716aa3c83 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,38 @@ test(`Should return 11 when given an ace card`, () => { expect(getCardValue("A♠")).toEqual(11); }); +// Case 2: Number Cards (2-10) +test(`Should return correct values for number cards`, () => { + expect(getCardValue("2♠")).toEqual(2); + expect(getCardValue("7♥")).toEqual(7); + expect(getCardValue("9♦")).toEqual(9); + expect(getCardValue("10♣")).toEqual(10); +}); + +// Case 3: 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: Invalid cards +test(`Should throw an error for invalid rank`, () => { + expect(() => getCardValue("1♠")).toThrowError("Invalid rank"); +}); + +test(`Should throw an error for invalid suit`, () => { + expect(() => getCardValue("A?")).toThrowError("Invalid suit"); +}); + +test(`Should throw an error for missing suit`, () => { + expect(() => getCardValue("A")).toThrowError(); +}); + +test(`Should throw an error for empty string`, () => { + expect(() => getCardValue("")).toThrowError(); +}); + // Suggestion: Group the remaining test data into these categories: // Number Cards (2-10) // Face Cards (J, Q, K) @@ -17,4 +49,3 @@ test(`Should return 11 when given an ace card`, () => { // 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 baa070c015bce2c9b7014cefe47914bbaa9d0ab8 Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Sat, 27 Jun 2026 12:26:07 +0100 Subject: [PATCH 3/7] written jest tests for all the three functions and tests returned as expected --- Sprint-3/2-practice-tdd/count.test.js | 19 ++++++++++++ .../2-practice-tdd/get-ordinal-number.test.js | 29 +++++++++++++++++++ Sprint-3/2-practice-tdd/repeat-str.js | 4 +-- Sprint-3/2-practice-tdd/repeat-str.test.js | 19 +++++++++++- 4 files changed, 68 insertions(+), 3 deletions(-) diff --git a/Sprint-3/2-practice-tdd/count.test.js b/Sprint-3/2-practice-tdd/count.test.js index 179ea0ddf7..1a5c294214 100644 --- a/Sprint-3/2-practice-tdd/count.test.js +++ b/Sprint-3/2-practice-tdd/count.test.js @@ -18,6 +18,25 @@ test("should count multiple occurrences of a character", () => { }); // Scenario: No Occurrences +test(`should return zero the character doesn't exist in the string`, () => { + const str = "bravo"; + const char = "u"; + const count = countChar(str, char); + expect(count).toEqual(0); +}); + +// Empty String +test(`should return zero when the string is empty`, () => { + expect(countChar("", "a")).toEqual(0); +}); + +// Scenario: Multiple Occurrences +test("should count multiple occurrences of characters (including mixed and case-sensitive)", () => { + expect(countChar("aaaaa", "a")).toEqual(5); // simple multiple + expect(countChar("1-2-3-4-5-", "-")).toEqual(5); // mixed characters + expect(countChar("AaAa", "A")).toEqual(2); // case sensitivity +}); + // Given the input string `str`, // And a character `char` that does not exist within `str`. // When the function is called with these inputs, 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..17b39984bc 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.test.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.test.js @@ -13,8 +13,37 @@ const getOrdinalNumber = require("./get-ordinal-number"); // Case 1: Numbers ending with 1 (but not 11) // When the number ends with 1, except those ending with 11, // Then the function should return a string by appending "st" to the number. + test("should append 'st' for numbers ending with 1, except those ending with 11", () => { expect(getOrdinalNumber(1)).toEqual("1st"); expect(getOrdinalNumber(21)).toEqual("21st"); expect(getOrdinalNumber(131)).toEqual("131st"); }); + +// Case 2: Numbers ending with 2 (but NOT 12) +test("should append 'nd' for numbers ending with 2, except those ending with 12", () => { + expect(getOrdinalNumber(2)).toEqual("2nd"); + expect(getOrdinalNumber(22)).toEqual("22nd"); + expect(getOrdinalNumber(102)).toEqual("102"); +}); + +// Case 3: Numbers ending with 3 (but NOT 13) +test("should append 'rd' for numbers ending with 3, except those ending with 13", () => { + expect(getOrdinalNumber(3)).toEqual("3rd"); + expect(getOrdinalNumber(33)).toEqual("33rd"); + expect(getOrdinalNumber(103)).toEqual("103rd"); +}); + +// Case 4: Numbers ending with 11, 12, or 13 --- 11,12,13,111,121,131, +test("should append 'th' for numbers ending with 11, 12, 13", () => { + expect(getOrdinalNumber(11)).toEqual("11th"); + expect(getOrdinalNumber(12)).toEqual("12th"); + expect(getOrdinalNumber(13)).toEqual("13th"); +}); + +// Case 5: Numbers ending with larger numbers of 111, 121, 131 +test("should append 'th' for numbers ending with 111, 121, 131", () => { + expect(getOrdinalNumber(111)).toEqual("111th"); + expect(getOrdinalNumber(121)).toEqual("121th"); + expect(getOrdinalNumber(131)).toEqual("131th"); +}); diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index 2af0a2cea7..a81b63cd1b 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -1,7 +1,7 @@ -function repeatStr() { +function repeatStr(str, count) { // 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"; + return str.repeat(count); } 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 a3fc1196c4..e6e5058df6 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.test.js +++ b/Sprint-3/2-practice-tdd/repeat-str.test.js @@ -11,22 +11,39 @@ const repeatStr = require("./repeat-str"); test("should repeat the string count times", () => { const str = "hello"; - const count = 3; + const count = -5; const repeatedStr = repeatStr(str, count); expect(repeatedStr).toEqual("hellohellohello"); }); // Case: handle count of 1: +test("should repeat the string count of 1", () => { + const str = "fella"; + const count = 1; + const repeatedStr = repeatStr(str, count); + expect(repeatedStr).toEqual("fella"); +}); + // Given a target string `str` and a `count` equal to 1, // When the repeatStr function is called with these inputs, // Then it should return the original `str` without repetition. // Case: Handle count of 0: +test("should repeat the string count of 0", () => { + const str = "fella"; + const count = 0; + const repeatedStr = repeatStr(str, count); + expect(repeatedStr).toEqual(""); +}); + // Given a target string `str` and a `count` equal to 0, // When the repeatStr function is called with these inputs, // Then it should return an empty string. // Case: Handle negative count: +test(`should throw an error for negative count`, () => { + expect(() => repeatedStr("fella", -2)).toThrowError(); +}); // Given a target string `str` and a negative integer `count`, // When the repeatStr function is called with these inputs, // Then it should throw an error, as negative counts are not valid. From 7bcf4846b644b35fc0c7546022284374f7bfe7b8 Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Sat, 27 Jun 2026 15:29:12 +0100 Subject: [PATCH 4/7] removed the redundant and unreachable codes --- Sprint-3/3-dead-code/exercise-1.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index 4d09f15fa9..50e520e1cb 100644 --- a/Sprint-3/3-dead-code/exercise-1.js +++ b/Sprint-3/3-dead-code/exercise-1.js @@ -5,13 +5,10 @@ let testName = "Jerry"; const greeting = "hello"; function sayHello(greeting, name) { - const greetingStr = greeting + ", " + name + "!"; + // const greetingStr = greeting + ", " + name + "!"; this line will also be removed because the we're trying to return something else, not the greetingStr and apparently it is a redundant code return `${greeting}, ${name}!`; - console.log(greetingStr); + // console.log(greetingStr); this line will obviously be omitted as it is unreachable code because it is written after return. In fact, anything after return is not reachable and should be get rid of } -testName = "Aman"; - const greetingMessage = sayHello(greeting, testName); - -console.log(greetingMessage); // 'hello, Aman!' +console.log(greetingMessage); From a0be617e5c0de573263a83aa8a11ae2cb4851364 Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Sat, 27 Jun 2026 15:34:47 +0100 Subject: [PATCH 5/7] fix: revert files to orginal --- Sprint-3/2-practice-tdd/count.test.js | 19 ------------ .../2-practice-tdd/get-ordinal-number.test.js | 29 ------------------- Sprint-3/2-practice-tdd/repeat-str.js | 4 +-- Sprint-3/2-practice-tdd/repeat-str.test.js | 19 +----------- 4 files changed, 3 insertions(+), 68 deletions(-) diff --git a/Sprint-3/2-practice-tdd/count.test.js b/Sprint-3/2-practice-tdd/count.test.js index 1a5c294214..179ea0ddf7 100644 --- a/Sprint-3/2-practice-tdd/count.test.js +++ b/Sprint-3/2-practice-tdd/count.test.js @@ -18,25 +18,6 @@ test("should count multiple occurrences of a character", () => { }); // Scenario: No Occurrences -test(`should return zero the character doesn't exist in the string`, () => { - const str = "bravo"; - const char = "u"; - const count = countChar(str, char); - expect(count).toEqual(0); -}); - -// Empty String -test(`should return zero when the string is empty`, () => { - expect(countChar("", "a")).toEqual(0); -}); - -// Scenario: Multiple Occurrences -test("should count multiple occurrences of characters (including mixed and case-sensitive)", () => { - expect(countChar("aaaaa", "a")).toEqual(5); // simple multiple - expect(countChar("1-2-3-4-5-", "-")).toEqual(5); // mixed characters - expect(countChar("AaAa", "A")).toEqual(2); // case sensitivity -}); - // Given the input string `str`, // And a character `char` that does not exist within `str`. // When the function is called with these inputs, 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 17b39984bc..adfa58560f 100644 --- a/Sprint-3/2-practice-tdd/get-ordinal-number.test.js +++ b/Sprint-3/2-practice-tdd/get-ordinal-number.test.js @@ -13,37 +13,8 @@ const getOrdinalNumber = require("./get-ordinal-number"); // Case 1: Numbers ending with 1 (but not 11) // When the number ends with 1, except those ending with 11, // Then the function should return a string by appending "st" to the number. - test("should append 'st' for numbers ending with 1, except those ending with 11", () => { expect(getOrdinalNumber(1)).toEqual("1st"); expect(getOrdinalNumber(21)).toEqual("21st"); expect(getOrdinalNumber(131)).toEqual("131st"); }); - -// Case 2: Numbers ending with 2 (but NOT 12) -test("should append 'nd' for numbers ending with 2, except those ending with 12", () => { - expect(getOrdinalNumber(2)).toEqual("2nd"); - expect(getOrdinalNumber(22)).toEqual("22nd"); - expect(getOrdinalNumber(102)).toEqual("102"); -}); - -// Case 3: Numbers ending with 3 (but NOT 13) -test("should append 'rd' for numbers ending with 3, except those ending with 13", () => { - expect(getOrdinalNumber(3)).toEqual("3rd"); - expect(getOrdinalNumber(33)).toEqual("33rd"); - expect(getOrdinalNumber(103)).toEqual("103rd"); -}); - -// Case 4: Numbers ending with 11, 12, or 13 --- 11,12,13,111,121,131, -test("should append 'th' for numbers ending with 11, 12, 13", () => { - expect(getOrdinalNumber(11)).toEqual("11th"); - expect(getOrdinalNumber(12)).toEqual("12th"); - expect(getOrdinalNumber(13)).toEqual("13th"); -}); - -// Case 5: Numbers ending with larger numbers of 111, 121, 131 -test("should append 'th' for numbers ending with 111, 121, 131", () => { - expect(getOrdinalNumber(111)).toEqual("111th"); - expect(getOrdinalNumber(121)).toEqual("121th"); - expect(getOrdinalNumber(131)).toEqual("131th"); -}); diff --git a/Sprint-3/2-practice-tdd/repeat-str.js b/Sprint-3/2-practice-tdd/repeat-str.js index a81b63cd1b..2af0a2cea7 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.js +++ b/Sprint-3/2-practice-tdd/repeat-str.js @@ -1,7 +1,7 @@ -function repeatStr(str, count) { +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 str.repeat(count); + return "hellohellohello"; } 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 e6e5058df6..a3fc1196c4 100644 --- a/Sprint-3/2-practice-tdd/repeat-str.test.js +++ b/Sprint-3/2-practice-tdd/repeat-str.test.js @@ -11,39 +11,22 @@ const repeatStr = require("./repeat-str"); test("should repeat the string count times", () => { const str = "hello"; - const count = -5; + const count = 3; const repeatedStr = repeatStr(str, count); expect(repeatedStr).toEqual("hellohellohello"); }); // Case: handle count of 1: -test("should repeat the string count of 1", () => { - const str = "fella"; - const count = 1; - const repeatedStr = repeatStr(str, count); - expect(repeatedStr).toEqual("fella"); -}); - // Given a target string `str` and a `count` equal to 1, // When the repeatStr function is called with these inputs, // Then it should return the original `str` without repetition. // Case: Handle count of 0: -test("should repeat the string count of 0", () => { - const str = "fella"; - const count = 0; - const repeatedStr = repeatStr(str, count); - expect(repeatedStr).toEqual(""); -}); - // Given a target string `str` and a `count` equal to 0, // When the repeatStr function is called with these inputs, // Then it should return an empty string. // Case: Handle negative count: -test(`should throw an error for negative count`, () => { - expect(() => repeatedStr("fella", -2)).toThrowError(); -}); // Given a target string `str` and a negative integer `count`, // When the repeatStr function is called with these inputs, // Then it should throw an error, as negative counts are not valid. From 8a5a9f0c687f0c8f231cabaf52beb21402ba38f6 Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Sat, 27 Jun 2026 15:42:39 +0100 Subject: [PATCH 6/7] fix; revert to original --- Sprint-3/3-dead-code/exercise-1.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index 50e520e1cb..4d09f15fa9 100644 --- a/Sprint-3/3-dead-code/exercise-1.js +++ b/Sprint-3/3-dead-code/exercise-1.js @@ -5,10 +5,13 @@ let testName = "Jerry"; const greeting = "hello"; function sayHello(greeting, name) { - // const greetingStr = greeting + ", " + name + "!"; this line will also be removed because the we're trying to return something else, not the greetingStr and apparently it is a redundant code + const greetingStr = greeting + ", " + name + "!"; return `${greeting}, ${name}!`; - // console.log(greetingStr); this line will obviously be omitted as it is unreachable code because it is written after return. In fact, anything after return is not reachable and should be get rid of + console.log(greetingStr); } +testName = "Aman"; + const greetingMessage = sayHello(greeting, testName); -console.log(greetingMessage); + +console.log(greetingMessage); // 'hello, Aman!' From 033144b4c8eb2815ddbe5ce6b85ad429f6fbd69f Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Sat, 27 Jun 2026 16:23:13 +0100 Subject: [PATCH 7/7] Refactor isProperFraction to remove zero numerator check Remove check for zero numerator in isProperFraction function. --- .../implement/2-is-proper-fraction.js | 3 --- 1 file changed, 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 50858ea196..42d7428736 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,6 @@ // execute the code to ensure all tests pass. function isProperFraction(numerator, denominator) { - if (numerator === 0) { - return false; - } if (denominator === 0) { return false; }