From ef3639191ea79409e331d80c83c3f86dc350551b Mon Sep 17 00:00:00 2001 From: Tomislav Dukez Date: Fri, 3 Jul 2026 09:22:58 +0100 Subject: [PATCH 1/3] fix mistakes in sayHello exercise --- Sprint-3/3-dead-code/exercise-1.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index 4d09f15fa9..7df5734c68 100644 --- a/Sprint-3/3-dead-code/exercise-1.js +++ b/Sprint-3/3-dead-code/exercise-1.js @@ -1,13 +1,13 @@ // 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"; -> we can initialize the variable without giving it a value because the testName is being reassigned later in the code. The value "Jerry" never appears in a function call. const greeting = "hello"; function sayHello(greeting, name) { - const greetingStr = greeting + ", " + name + "!"; + // const greetingStr = greeting + ", " + name + "!"; -> this line is not necessary because the returned string accomplishes the same thing, and the greetingStr is never being used. So it is redundant code and can be removed. return `${greeting}, ${name}!`; - console.log(greetingStr); + // console.log(greetingStr); -> this line is never being executed because it comes after the return statement, so it never runs and can be removed. } testName = "Aman"; From a969de2361bb2ac30af8840ae0a20b296abd864a Mon Sep 17 00:00:00 2001 From: Tomislav Dukez Date: Fri, 3 Jul 2026 09:31:49 +0100 Subject: [PATCH 2/3] fix mistakes in countAndCapitalisePets exercise --- Sprint-3/3-dead-code/exercise-2.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-2.js b/Sprint-3/3-dead-code/exercise-2.js index 56d7887c4c..eb9ba68edb 100644 --- a/Sprint-3/3-dead-code/exercise-2.js +++ b/Sprint-3/3-dead-code/exercise-2.js @@ -2,12 +2,13 @@ // 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 capitalisedPets = pets.map((pet) => pet.toUpperCase()); -> this line is not necessary because the same functionality is implemented inside the function countAndCapitalisePets. +// Also, the variable capitalisedPets in not being used in the global scope const petsStartingWithH = pets.filter((pet) => pet[0] === "h"); -function logPets(petsArr) { - petsArr.forEach((pet) => console.log(pet)); -} +// function logPets(petsArr) { +// petsArr.forEach((pet) => console.log(pet)); +// } -> This function is not being used/called anywhere in the program, it is redundant code and should be removed. function countAndCapitalisePets(petsArr) { const petCount = {}; From 83bf403e8a5e1eff139f9844385f2ed67a2d3712 Mon Sep 17 00:00:00 2001 From: Tomislav Dukez Date: Fri, 3 Jul 2026 09:37:06 +0100 Subject: [PATCH 3/3] fix remove dead code --- Sprint-3/3-dead-code/exercise-1.js | 4 +--- Sprint-3/3-dead-code/exercise-2.js | 7 +------ 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index 7df5734c68..3f666d0e82 100644 --- a/Sprint-3/3-dead-code/exercise-1.js +++ b/Sprint-3/3-dead-code/exercise-1.js @@ -1,13 +1,11 @@ // 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"; -> we can initialize the variable without giving it a value because the testName is being reassigned later in the code. The value "Jerry" never appears in a function call. +let testName; const greeting = "hello"; function sayHello(greeting, name) { - // const greetingStr = greeting + ", " + name + "!"; -> this line is not necessary because the returned string accomplishes the same thing, and the greetingStr is never being used. So it is redundant code and can be removed. return `${greeting}, ${name}!`; - // console.log(greetingStr); -> this line is never being executed because it comes after the return statement, so it never runs and can be removed. } testName = "Aman"; diff --git a/Sprint-3/3-dead-code/exercise-2.js b/Sprint-3/3-dead-code/exercise-2.js index eb9ba68edb..1d292f2f8c 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()); -> this line is not necessary because the same functionality is implemented inside the function countAndCapitalisePets. -// Also, the variable capitalisedPets in not being used in the global scope -const petsStartingWithH = pets.filter((pet) => pet[0] === "h"); -// function logPets(petsArr) { -// petsArr.forEach((pet) => console.log(pet)); -// } -> This function is not being used/called anywhere in the program, it is redundant code and should be removed. +const petsStartingWithH = pets.filter((pet) => pet[0] === "h"); function countAndCapitalisePets(petsArr) { const petCount = {};