From 61d68a83051ab62c470ebcc6e3c7fd0ce3d035fb Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Sun, 8 Mar 2026 17:18:51 +0000 Subject: [PATCH 01/12] created function getAngleType(angle) and wrote tests to cover all cases --- .../implement/1-get-angle-type.js | 35 +++++++++++++++++-- 1 file changed, 32 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 9e05a871e..8060e0de6 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,12 @@ // execute the code to ensure all tests pass. function getAngleType(angle) { - // TODO: Implement this function + if (angle < 0 || angle >= 360) return "Invalid angle"; + if (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"; + return "Reflex angle"; } // The line below allows us to load the getAngleType function into tests in other files. @@ -31,7 +36,31 @@ function assertEquals(actualOutput, targetOutput) { ); } -// TODO: Write tests to cover all cases, including boundary and invalid cases. -// Example: Identify Right Angles const right = getAngleType(90); assertEquals(right, "Right angle"); + +const acute = getAngleType(45); +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"); + +const invalid = getAngleType(-10); +assertEquals(invalid, "Invalid angle"); + +const invalid2 = getAngleType(360); +assertEquals(invalid2, "Invalid angle"); + +console.log(getAngleType(20)); +console.log(getAngleType(90)); +console.log(getAngleType(120)); +console.log(getAngleType(180)); +console.log(getAngleType(270)); +console.log(getAngleType(-10)); +console.log(getAngleType(360)); From 70c2e4f865af2f5411d4002905a8777426b36fb8 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Sun, 8 Mar 2026 18:07:08 +0000 Subject: [PATCH 02/12] completed function, wrote assertions and console.log to check --- .../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 970cb9b64..939ee6d37 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,9 @@ // execute the code to ensure all tests pass. function isProperFraction(numerator, denominator) { - // TODO: Implement this function + if (denominator === 0) return false; // A fraction with a zero denominator is not valid + if (Math.abs(numerator) >= Math.abs(denominator)) return false; // Not a proper fraction + return true; // Is a proper fraction } // The line below allows us to load the isProperFraction function into tests in other files. @@ -31,3 +33,15 @@ function assertEquals(actualOutput, targetOutput) { // Example: 1/2 is a proper fraction assertEquals(isProperFraction(1, 2), true); +assertEquals(isProperFraction(2, 2), false); +assertEquals(isProperFraction(2, 1), false); +assertEquals(isProperFraction(0, 2), true); +assertEquals(isProperFraction(1, 0), false); +assertEquals(isProperFraction(0, 0), false); + +console.log(isProperFraction(1, 2)); +console.log(isProperFraction(2, 2)); +console.log(isProperFraction(2, 1)); +console.log(isProperFraction(0, 2)); +console.log(isProperFraction(1, 0)); +console.log(isProperFraction(0, 0)); \ No newline at end of file From a979c9149734f9f9291888864ffe1cbe6462db2e Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Sun, 8 Mar 2026 23:19:56 +0000 Subject: [PATCH 03/12] added assert, try and catch, console log --- .../implement/3-get-card-value.js | 75 ++++++++++++++++++- 1 file changed, 72 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 c7559e787..ad0e4c1d2 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,32 @@ // execute the code to ensure all tests pass. function getCardValue(card) { - // TODO: Implement this function -} + + if (typeof card !== "string" || card.length < 2) { + throw new Error("Invalid card"); + } +// Handle "10" which is 2 characters + if (card.startsWith("10")) { + return 10; + } + + const firstChar = card[0]; + + // check if picture cards + if (firstChar === "A") return 11; + if (firstChar === "J" || firstChar === "Q" || firstChar === "K" ) return 10; + + // check if number is between 2 and 9, 10 has already been checked for and there should be no other valid cards + + const num = Number(firstChar); + if (!isNaN(num) && num >= 2 && num <= 9) { + return num; + // for everything else + } else { + throw new Error("Invalid card"); + } +} // 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; @@ -40,13 +63,59 @@ function assertEquals(actualOutput, targetOutput) { // TODO: Write tests to cover all outcomes, including throwing errors for invalid cards. // Examples: assertEquals(getCardValue("9♠"), 9); +assertEquals(getCardValue("10♥"), 10); +assertEquals(getCardValue("J♥"), 10); +assertEquals(getCardValue("A♠"), 11); +assertEquals(getCardValue("Q♦"), 10); +assertEquals(getCardValue("K♣"), 10); // Handling invalid cards +try { + getCardValue("♠J"); + console.error("Error was not thrown for invalid card"); +} catch (e) {} + try { getCardValue("invalid"); + console.error("Error was not thrown for invalid card"); +} catch (e) {} - // This line will not be reached if an error is thrown as expected +// Handling invalid cards +try { + getCardValue("♠J"); console.error("Error was not thrown for invalid card"); } catch (e) {} +try { + getCardValue("invalid"); + console.error("Error was not thrown for invalid card"); +} catch (e) {} + + +try { + getCardValue("♠J"); + console.error("Error was not thrown for invalid card"); +} catch (e) { + console.log("Invalid card detected"); +} + +try { + getCardValue("invalid"); + console.error("Error was not thrown for invalid card"); +} catch (e) {} + +console.log(getCardValue("9♠")); +console.log(getCardValue("10♥")); +console.log(getCardValue("J♥")); +console.log(getCardValue("A♠")); +console.log(getCardValue("Q♦")); +console.log(getCardValue("K♣")); + + // This line will not be reached if an error is thrown as expected +try { +sole.error("Error was not thrown for invalid card"); +} catch (e) {} + // What other invalid card cases can you think of? +// There could be cards with special characters +// There could be cards with two numbers rather than a number and a suite From 73862c581a133f381eeac1b107b77808a19ceb70 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 9 Mar 2026 10:11:39 +0000 Subject: [PATCH 04/12] added test cases for angles --- .../implement/1-get-angle-type.js | 2 +- .../1-get-angle-type.test.js | 35 +++++++++++++++++-- 2 files changed, 33 insertions(+), 4 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 8060e0de6..545f1c41a 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 @@ -25,8 +25,8 @@ function getAngleType(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; +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) { 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 d777f348d..94eac95b0 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 @@ -2,19 +2,48 @@ // We will use the same function, but write tests for it using Jest in this file. const getAngleType = require("../implement/1-get-angle-type"); -// TODO: Write tests in Jest syntax to cover all cases/outcomes, -// including boundary and invalid cases. - // Case 1: Acute angles 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(91)).toEqual("Obtuse angle"); }); // Case 2: Right angle +test(`should return "Right angle" when (angle === 90)`, () => { + // Test various right angles, including boundary cases + expect(getAngleType(90)).toEqual("Right angle"); + expect(getAngleType(89)).toEqual("Acute angle"); + expect(getAngleType(91)).toEqual("Obtuse angle"); +}); + // Case 3: Obtuse angles +test(`should return "Obtuse angle" when (angle > 90) && when (angle < 180)`, () => { + // Test various obtuse angles, including boundary cases + expect(getAngleType(91)).toEqual("Obtuse angle"); + expect(getAngleType(150)).toEqual("Obtuse angle"); + expect(getAngleType(189)).toEqual("Reflex angle"); +}); + // Case 4: Straight angle +test(`should return "Straight angle" when (angle === 180)`, () => { + // Test various straight angles, including boundary cases + expect(getAngleType(180)).toEqual("Straight angle"); + expect(getAngleType(179)).toEqual("Obtuse angle"); + expect(getAngleType(181)).toEqual("Reflex angle"); +}); + // Case 5: Reflex angles +test(`should return "Reflex angle" when (angle > 180)`, () => { + expect(getAngleType(181)).toEqual("Reflex angle"); + expect(getAngleType(270)).toEqual("Reflex angle"); + expect(getAngleType(359)).toEqual("Reflex angle"); +}); + // Case 6: Invalid angles +test(`should return "Invalid angle" when (angle < 0 || angle >= 360)`, () => { + expect(getAngleType(-1)).toEqual("Invalid angle"); + expect(getAngleType(360)).toEqual("Invalid angle"); +}); From 44c463c13a19f3541a305aae9b8f7826cfb19666 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 9 Mar 2026 10:28:07 +0000 Subject: [PATCH 05/12] added tests --- .../implement/2-is-proper-fraction.js | 2 +- .../2-is-proper-fraction.test.js | 22 +++++++++++++++++-- 2 files changed, 21 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 939ee6d37..574470b7e 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 @@ -44,4 +44,4 @@ console.log(isProperFraction(2, 2)); console.log(isProperFraction(2, 1)); console.log(isProperFraction(0, 2)); console.log(isProperFraction(1, 0)); -console.log(isProperFraction(0, 0)); \ No newline at end of file +console.log(isProperFraction(0, 0)); 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 7f087b2ba..356903e40 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 @@ -2,9 +2,27 @@ // We will use the same function, but write tests for it using Jest in this file. 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 false when denominator is zero`, () => { expect(isProperFraction(1, 0)).toEqual(false); }); + +test(`should return false when denominator is zero`, () => { + expect(isProperFraction(1, 2)).toEqual(true); +}); + +test(`should return false when denominator is zero`, () => { + expect(isProperFraction(2, 2)).toEqual(false); +}); + +test(`should return false when denominator is zero`, () => { + expect(isProperFraction(2, 1)).toEqual(false); +}); + +test(`should return false when denominator is zero`, () => { + expect(isProperFraction(0, 0)).toEqual(false); +}); + +test(`should return false when denominator is zero`, () => { + expect(isProperFraction(0, 1)).toEqual(true); +}); From e3943d2348f7eeae5dd4446e7f5ab2477ed6da94 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 9 Mar 2026 11:40:33 +0000 Subject: [PATCH 06/12] tested cards with jest and updated comments --- .../implement/3-get-card-value.js | 65 ++++++++++--------- .../3-get-card-value.test.js | 52 ++++++++++++--- 2 files changed, 76 insertions(+), 41 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 ad0e4c1d2..8efc14733 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,20 +22,28 @@ // execute the code to ensure all tests pass. function getCardValue(card) { - if (typeof card !== "string" || card.length < 2) { - throw new Error("Invalid card"); + throw new Error("Invalid card"); } -// Handle "10" which is 2 characters + // Handle "10" which is like "10♥" if (card.startsWith("10")) { return 10; } + //if more than 2 characters and not starting with a 10 card + if (card.length > 2) { + throw new Error("Invalid card"); + } + + // remaining cards must be 2 characters long + + const validSuits = ["♠", "♥", "♦", "♣"]; + const suit = card[card.length - 1]; const firstChar = card[0]; // check if picture cards if (firstChar === "A") return 11; - if (firstChar === "J" || firstChar === "Q" || firstChar === "K" ) return 10; + if (firstChar === "J" || firstChar === "Q" || firstChar === "K") return 10; // check if number is between 2 and 9, 10 has already been checked for and there should be no other valid cards @@ -43,10 +51,10 @@ function getCardValue(card) { if (!isNaN(num) && num >= 2 && num <= 9) { return num; - // for everything else - } else { - throw new Error("Invalid card"); - } + // for everything else + } else { + throw new Error("Invalid card"); + } } // 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. @@ -69,17 +77,6 @@ assertEquals(getCardValue("A♠"), 11); assertEquals(getCardValue("Q♦"), 10); assertEquals(getCardValue("K♣"), 10); -// Handling invalid cards -try { - getCardValue("♠J"); - console.error("Error was not thrown for invalid card"); -} catch (e) {} - -try { - getCardValue("invalid"); - console.error("Error was not thrown for invalid card"); -} catch (e) {} - // Handling invalid cards try { getCardValue("♠J"); @@ -91,16 +88,8 @@ try { console.error("Error was not thrown for invalid card"); } catch (e) {} - try { - getCardValue("♠J"); - console.error("Error was not thrown for invalid card"); -} catch (e) { - console.log("Invalid card detected"); -} - -try { - getCardValue("invalid"); + getCardValue("22"); console.error("Error was not thrown for invalid card"); } catch (e) {} @@ -110,12 +99,24 @@ console.log(getCardValue("J♥")); console.log(getCardValue("A♠")); console.log(getCardValue("Q♦")); console.log(getCardValue("K♣")); - - // This line will not be reached if an error is thrown as expected + +// This line will not be reached if an error is thrown as expected try { -sole.error("Error was not thrown for invalid card"); + console.error("Error was not thrown for invalid card"); } catch (e) {} // What other invalid card cases can you think of? -// There could be cards with special characters + +// There could be cards with special characters. + // There could be cards with two numbers rather than a number and a suite +// These will not be picked up because the code only checks for if starts with 10 or if the first character +// is a number between 2 and 9, so cards like "22" would be valid because the first number +// is 2, but the second character is not checked for validity. It is also 2 characters +// so will not cause an error when the length is checked. + +// Since the second character is not checked it could be 2D which is not a valid card but +// would be accepted because the first character is 2 and the second character is not checked for validity + +// When the card is checked if it begins with 10 it does check if it has a valid suite +// as only the first 2 characters are checked so it could be 10DEVON or 10♥♥. 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 cf7f9dae2..f215e37b4 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 @@ -1,20 +1,54 @@ // This statement loads the getCardValue function you wrote in the implement directory. // We will use the same function, but write tests for it using Jest in this file. +const { createTestScheduler } = require("jest"); 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); }); -// Suggestion: Group the remaining test data into these categories: -// Number Cards (2-10) -// Face Cards (J, Q, K) -// Invalid Cards +// Case 2: Face Cards (J, Q, K) +test(`Should return 10 when given a Jack card`, () => { + expect(getCardValue("J♥")).toEqual(10); +}); -// 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 10 when given a Queen card`, () => { + expect(getCardValue("Q♦")).toEqual(10); +}); + +test(`Should return 10 when given a King card`, () => { + expect(getCardValue("K♣")).toEqual(10); +}); + +// Case 3: Number Cards (2-10) +test(`Should return 2 when given a 2 card`, () => { + expect(getCardValue("2♠")).toEqual(2); +}); + +test(`Should return 10 when given a 10 card`, () => { + expect(getCardValue("10♥")).toEqual(10); +}); + +// Case 4: Invalid Cards +test(`Should throw an error when given an invalid card`, () => { + expect(() => getCardValue("♠J")).toThrow(); +}); + +test(`Should throw an error when given an invalid card`, () => { + expect(() => getCardValue("invalid")).toThrow(); +}); + +test(`Should throw an error when given an invalid card`, () => { + expect(() => getCardValue("12♠")).toThrow(); +}); + +test(`Should throw an error when given an invalid card`, () => { + expect(() => getCardValue("1")).toThrow(); +}); +// when I tested with test(`Should throw an error when given an invalid card`, () => { +// expect(() => getCardValue("22")).toThrow(); it did not throw an error because 22 passes the +// test of first number between and 9 and being 2 characters long, +// but it is not a valid card because the second character is not a valid suite. +// The second character is not checked. From bddc0bb5043e89d114bb66f84d2b5e9dfaaa8602 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 9 Mar 2026 12:45:56 +0000 Subject: [PATCH 07/12] wrote test then function and checked --- Sprint-3/2-practice-tdd/count.js | 10 +++++++- Sprint-3/2-practice-tdd/count.test.js | 35 +++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/Sprint-3/2-practice-tdd/count.js b/Sprint-3/2-practice-tdd/count.js index 95b6ebb7d..288c024c1 100644 --- a/Sprint-3/2-practice-tdd/count.js +++ b/Sprint-3/2-practice-tdd/count.js @@ -1,5 +1,13 @@ function countChar(stringOfCharacters, findCharacter) { - return 5 + + let count = 0; + + for (let char of stringOfCharacters) { + if (char === findCharacter) { + count++; + } + } + return count; } module.exports = countChar; diff --git a/Sprint-3/2-practice-tdd/count.test.js b/Sprint-3/2-practice-tdd/count.test.js index 179ea0ddf..476cc2cad 100644 --- a/Sprint-3/2-practice-tdd/count.test.js +++ b/Sprint-3/2-practice-tdd/count.test.js @@ -22,3 +22,38 @@ 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 count multiple occurrences of a character", () => { + const str = "blind"; + const char = "a"; + const count = countChar(str, char); + expect(count).toEqual(0); +}); + +test("should count multiple occurrences of a character", () => { + const str = "blood"; + const char = "o"; + const count = countChar(str, char); + expect(count).toEqual(2); +}); + +test("should count multiple occurrences of a character", () => { + const str = "blood"; + const char = "l"; + const count = countChar(str, char); + expect(count).toEqual(1); +}); + +test("should count multiple occurrences of a character", () => { + const str = "bbbrf"; + const char = "b"; + const count = countChar(str, char); + expect(count).toEqual(3); +}); + +test("should count multiple occurrences of a character", () => { + const str = "ooooa"; + const char = "o"; + const count = countChar(str, char); + expect(count).toEqual(4); +}); From e235397d5d12f475133d6d8140fade0bbe37d0c1 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Mon, 9 Mar 2026 15:35:26 +0000 Subject: [PATCH 08/12] Delete Sprint-3/2-practice-tdd/count.js --- Sprint-3/2-practice-tdd/count.js | 13 ------------- 1 file changed, 13 deletions(-) delete mode 100644 Sprint-3/2-practice-tdd/count.js diff --git a/Sprint-3/2-practice-tdd/count.js b/Sprint-3/2-practice-tdd/count.js deleted file mode 100644 index 288c024c1..000000000 --- a/Sprint-3/2-practice-tdd/count.js +++ /dev/null @@ -1,13 +0,0 @@ -function countChar(stringOfCharacters, findCharacter) { - - let count = 0; - - for (let char of stringOfCharacters) { - if (char === findCharacter) { - count++; - } - } - return count; -} - -module.exports = countChar; From 97db10117c0e5f2e3d9c227a7fc80564c3d84100 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Tue, 10 Mar 2026 21:50:36 +0000 Subject: [PATCH 09/12] deleted unneccessary lines, added const line 11 and comment line 13 --- Sprint-3/3-dead-code/exercise-1.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index 4d09f15fa..5ea3c6977 100644 --- a/Sprint-3/3-dead-code/exercise-1.js +++ b/Sprint-3/3-dead-code/exercise-1.js @@ -1,17 +1,15 @@ // Find the instances of unreachable and redundant code - remove them! // The sayHello function should continue to work for any reasonable input it's given. -let testName = "Jerry"; +//let testName = "Jerry"; const greeting = "hello"; function sayHello(greeting, name) { - const greetingStr = greeting + ", " + name + "!"; return `${greeting}, ${name}!`; - console.log(greetingStr); } -testName = "Aman"; +const testName = "Aman"; -const greetingMessage = sayHello(greeting, testName); +const greetingMessage = sayHello(greeting, testName); // only needed if want to store the variables console.log(greetingMessage); // 'hello, Aman!' From de2ab2ffd017efd88ec812be72b834da8ec6e88e Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Tue, 10 Mar 2026 22:35:41 +0000 Subject: [PATCH 10/12] removed dead code --- Sprint-3/3-dead-code/exercise-2.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-2.js b/Sprint-3/3-dead-code/exercise-2.js index 56d7887c4..4b999afbf 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 = {}; @@ -25,4 +20,4 @@ function countAndCapitalisePets(petsArr) { const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); -console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log +console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } From 002f8fe3c53cd15dd350d17ae1573223ddb20876 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Tue, 10 Mar 2026 22:39:50 +0000 Subject: [PATCH 11/12] Delete Sprint-3/3-dead-code/exercise-1.js --- Sprint-3/3-dead-code/exercise-1.js | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 Sprint-3/3-dead-code/exercise-1.js diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js deleted file mode 100644 index 5ea3c6977..000000000 --- a/Sprint-3/3-dead-code/exercise-1.js +++ /dev/null @@ -1,15 +0,0 @@ -// Find the instances of unreachable and redundant code - remove them! -// The sayHello function should continue to work for any reasonable input it's given. - -//let testName = "Jerry"; -const greeting = "hello"; - -function sayHello(greeting, name) { - return `${greeting}, ${name}!`; -} - -const testName = "Aman"; - -const greetingMessage = sayHello(greeting, testName); // only needed if want to store the variables - -console.log(greetingMessage); // 'hello, Aman!' From d074c28861edb026dd0a15c692f7240e502b8287 Mon Sep 17 00:00:00 2001 From: Hayriye Saricicek Date: Tue, 10 Mar 2026 22:41:01 +0000 Subject: [PATCH 12/12] Delete Sprint-3/3-dead-code/exercise-2.js --- Sprint-3/3-dead-code/exercise-2.js | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 Sprint-3/3-dead-code/exercise-2.js diff --git a/Sprint-3/3-dead-code/exercise-2.js b/Sprint-3/3-dead-code/exercise-2.js deleted file mode 100644 index 4b999afbf..000000000 --- a/Sprint-3/3-dead-code/exercise-2.js +++ /dev/null @@ -1,23 +0,0 @@ -// Remove the unused code that does not contribute to the final console log -// 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 petsStartingWithH = pets.filter((pet) => pet[0] === "h"); - -function countAndCapitalisePets(petsArr) { - const petCount = {}; - - petsArr.forEach((pet) => { - const capitalisedPet = pet.toUpperCase(); - if (petCount[capitalisedPet]) { - petCount[capitalisedPet] += 1; - } else { - petCount[capitalisedPet] = 1; - } - }); - return petCount; -} - -const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); - -console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 }