From 5fe338c8e7286a8b1f566c63237c616a362e5035 Mon Sep 17 00:00:00 2001 From: Poonam Rajput Date: Fri, 9 Jan 2026 14:34:42 +0000 Subject: [PATCH 1/7] Adding dead code backlog task --- Sprint-3/3-dead-code/README.md | 9 +++++++++ Sprint-3/3-dead-code/exercise-1.js | 17 +++++++++++++++++ Sprint-3/3-dead-code/exercise-2.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 Sprint-3/3-dead-code/README.md create mode 100644 Sprint-3/3-dead-code/exercise-1.js create mode 100644 Sprint-3/3-dead-code/exercise-2.js diff --git a/Sprint-3/3-dead-code/README.md b/Sprint-3/3-dead-code/README.md new file mode 100644 index 0000000000..2bfbfff819 --- /dev/null +++ b/Sprint-3/3-dead-code/README.md @@ -0,0 +1,9 @@ +# Refactoring Dead Code + +Here are two example of code that has not been built efficiently. Both files have dead code in them. It's your job to go back through this existing code, identify the dead code, and remove it so the code is ready for production. + +## Instructions + +1. Work through each `exercise` file inside this directory. +2. Delete the dead code. +3. Commit your changes and make a PR when done. diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js new file mode 100644 index 0000000000..4d09f15fa9 --- /dev/null +++ b/Sprint-3/3-dead-code/exercise-1.js @@ -0,0 +1,17 @@ +// 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) { + const greetingStr = greeting + ", " + name + "!"; + return `${greeting}, ${name}!`; + console.log(greetingStr); +} + +testName = "Aman"; + +const greetingMessage = sayHello(greeting, testName); + +console.log(greetingMessage); // 'hello, Aman!' diff --git a/Sprint-3/3-dead-code/exercise-2.js b/Sprint-3/3-dead-code/exercise-2.js new file mode 100644 index 0000000000..56d7887c4c --- /dev/null +++ b/Sprint-3/3-dead-code/exercise-2.js @@ -0,0 +1,28 @@ +// 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 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 = {}; + + 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 } <- Final console log From 9987ade9b575added958c4dc4d9d5c22ae888209 Mon Sep 17 00:00:00 2001 From: Poonam Rajput Date: Fri, 9 Jan 2026 14:35:01 +0000 Subject: [PATCH 2/7] reordering backlog tasks for sprint 3 due to added dead code work --- Sprint-3/{3-stretch => 4-stretch}/README.md | 0 Sprint-3/{3-stretch => 4-stretch}/card-validator.md | 0 Sprint-3/{3-stretch => 4-stretch}/find.js | 0 Sprint-3/{3-stretch => 4-stretch}/password-validator.js | 0 Sprint-3/{3-stretch => 4-stretch}/password-validator.test.js | 0 Sprint-3/readme.md | 4 +++- 6 files changed, 3 insertions(+), 1 deletion(-) rename Sprint-3/{3-stretch => 4-stretch}/README.md (100%) rename Sprint-3/{3-stretch => 4-stretch}/card-validator.md (100%) rename Sprint-3/{3-stretch => 4-stretch}/find.js (100%) rename Sprint-3/{3-stretch => 4-stretch}/password-validator.js (100%) rename Sprint-3/{3-stretch => 4-stretch}/password-validator.test.js (100%) diff --git a/Sprint-3/3-stretch/README.md b/Sprint-3/4-stretch/README.md similarity index 100% rename from Sprint-3/3-stretch/README.md rename to Sprint-3/4-stretch/README.md diff --git a/Sprint-3/3-stretch/card-validator.md b/Sprint-3/4-stretch/card-validator.md similarity index 100% rename from Sprint-3/3-stretch/card-validator.md rename to Sprint-3/4-stretch/card-validator.md diff --git a/Sprint-3/3-stretch/find.js b/Sprint-3/4-stretch/find.js similarity index 100% rename from Sprint-3/3-stretch/find.js rename to Sprint-3/4-stretch/find.js diff --git a/Sprint-3/3-stretch/password-validator.js b/Sprint-3/4-stretch/password-validator.js similarity index 100% rename from Sprint-3/3-stretch/password-validator.js rename to Sprint-3/4-stretch/password-validator.js diff --git a/Sprint-3/3-stretch/password-validator.test.js b/Sprint-3/4-stretch/password-validator.test.js similarity index 100% rename from Sprint-3/3-stretch/password-validator.test.js rename to Sprint-3/4-stretch/password-validator.test.js diff --git a/Sprint-3/readme.md b/Sprint-3/readme.md index 491afb81cc..983e3b1ff2 100644 --- a/Sprint-3/readme.md +++ b/Sprint-3/readme.md @@ -9,8 +9,10 @@ > Do the prep. This sprint you are expected to produce multiple different pull requests: + 1. One pull request for the `1-implement-and-rewrite-tests` directory. 2. One pull request for the `2-practice-tdd` directory. -3. Optionally, one pull request for the `3-stretch` directory. +3. As a stretch goal, one pull request for the `3-dead-code` directory. +4. Optionally, one pull request for the `4-stretch` directory. Each directory contains a README.md file with instructions for that directory. From 9a4527ac705fdbd355311513df03ee53842bb3f4 Mon Sep 17 00:00:00 2001 From: Poonam Rajput Date: Tue, 13 Jan 2026 12:27:21 +0000 Subject: [PATCH 3/7] make dead code required in readme --- Sprint-3/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/readme.md b/Sprint-3/readme.md index 983e3b1ff2..028950b927 100644 --- a/Sprint-3/readme.md +++ b/Sprint-3/readme.md @@ -12,7 +12,7 @@ This sprint you are expected to produce multiple different pull requests: 1. One pull request for the `1-implement-and-rewrite-tests` directory. 2. One pull request for the `2-practice-tdd` directory. -3. As a stretch goal, one pull request for the `3-dead-code` directory. +3. One pull request for the `3-dead-code` directory. 4. Optionally, one pull request for the `4-stretch` directory. Each directory contains a README.md file with instructions for that directory. From 27c88cab4f24a3683ddb3451b2825e0af4f35eb6 Mon Sep 17 00:00:00 2001 From: Poonam Rajput Date: Mon, 23 Mar 2026 15:06:52 +0000 Subject: [PATCH 4/7] reword to not push for tdd yet --- Sprint-3/1-implement-and-rewrite-tests/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/README.md b/Sprint-3/1-implement-and-rewrite-tests/README.md index a65bd2077c..79603bbe56 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/README.md +++ b/Sprint-3/1-implement-and-rewrite-tests/README.md @@ -8,7 +8,7 @@ to choose test values that thoroughly test a function. In the `implement` directory you've got a number of functions you'll need to implement. For each function, you also have a number of different cases you'll need to check for your function. -Write your assertions and build up your program case by case. Don't rush to a solution. The point of these assignments is to learn how to write assertions and build up a program step by step. +Write your implementation and then write your tests to cover the cases the function should fulfil. Here is a recommended order: From 1b3febeb8ee1f7fd9d6f316a6ac3fba28e122467 Mon Sep 17 00:00:00 2001 From: Poonam Rajput Date: Mon, 23 Mar 2026 15:14:37 +0000 Subject: [PATCH 5/7] making error handling clearer --- .../implement/3-get-card-value.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js index c7559e787e..370b82a3e2 100644 --- a/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js +++ b/Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js @@ -46,7 +46,9 @@ try { getCardValue("invalid"); // This line will not be reached if an error is thrown as expected - console.error("Error was not thrown for invalid card"); -} catch (e) {} + console.error("Error was not thrown for invalid card 😢"); +} catch (e) { + console.log("Error thrown for invalid card!"); +} // What other invalid card cases can you think of? From 6ab29abb50a06e1cbb6b7957ec41e6c0b8725212 Mon Sep 17 00:00:00 2001 From: Poonam Rajput Date: Mon, 23 Mar 2026 15:15:05 +0000 Subject: [PATCH 6/7] making error handling clearer --- .../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 370b82a3e2..ff5c532e1d 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 @@ -48,7 +48,7 @@ try { // This line will not be reached if an error is thrown as expected console.error("Error was not thrown for invalid card 😢"); } catch (e) { - console.log("Error thrown for invalid card!"); + console.log("Error thrown for invalid card 🎉"); } // What other invalid card cases can you think of? From da7d62cbe024bee9d77cf85d7cf36f9f5ef2df89 Mon Sep 17 00:00:00 2001 From: Poonam Rajput Date: Mon, 23 Mar 2026 15:17:09 +0000 Subject: [PATCH 7/7] console err instead of log --- .../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 ff5c532e1d..e16912b30a 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 @@ -48,7 +48,7 @@ try { // This line will not be reached if an error is thrown as expected console.error("Error was not thrown for invalid card 😢"); } catch (e) { - console.log("Error thrown for invalid card 🎉"); + console.error("Error thrown for invalid card 🎉"); } // What other invalid card cases can you think of?