From ad794ba1b5a4f6019755410a94c5a1a8943b733f Mon Sep 17 00:00:00 2001 From: Diana <40689028+ausiejute@users.noreply.github.com> Date: Sun, 18 Oct 2026 01:48:01 +0100 Subject: [PATCH 1/5] Remove instances of unreachable and redundant code - exercise 1 --- dead-code/exercise-1.js | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index 4d09f15fa9..5593f9e239 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,17 +1,6 @@ // 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!' From c7874fcefd6bedad9e616abcf07b4f061d1549e5 Mon Sep 17 00:00:00 2001 From: Diana <40689028+ausiejute@users.noreply.github.com> Date: Sun, 18 Oct 2026 23:41:14 +0100 Subject: [PATCH 2/5] Remove instances of unreachable and redundant code - exercise 2 --- dead-code/exercise-2.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index 56d7887c4c..d2c514c736 100644 --- a/dead-code/exercise-2.js +++ b/dead-code/exercise-2.js @@ -2,13 +2,9 @@ // 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()); const petsStartingWithH = pets.filter((pet) => pet[0] === "h"); -function logPets(petsArr) { - petsArr.forEach((pet) => console.log(pet)); -} - function countAndCapitalisePets(petsArr) { const petCount = {}; @@ -24,5 +20,3 @@ function countAndCapitalisePets(petsArr) { } const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); - -console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log From 0c7a6f90831ca474892c18d73341e5d77744f9e5 Mon Sep 17 00:00:00 2001 From: Diana <40689028+ausiejute@users.noreply.github.com> Date: Mon, 19 Oct 2026 01:13:42 +0100 Subject: [PATCH 3/5] Remove more unnecessary code - Exercise 2 --- dead-code/exercise-2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index d2c514c736..4537a4dbbf 100644 --- a/dead-code/exercise-2.js +++ b/dead-code/exercise-2.js @@ -2,7 +2,7 @@ // 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 countAndCapitalisePets(petsArr) { From a494ad020aa46cf4d5f5531bb663f85da8f0392b Mon Sep 17 00:00:00 2001 From: Diana <40689028+ausiejute@users.noreply.github.com> Date: Wed, 21 Oct 2026 15:06:45 +0100 Subject: [PATCH 4/5] Added incorrect deletions back --- dead-code/exercise-1.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index 5593f9e239..f0d6a1e3c4 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,6 +1,12 @@ // 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 greetingMessage = sayHello(greeting, testName); + +console.log(greetingMessage); From 434826896a84ff9a5e00bebb3730f965c941f866 Mon Sep 17 00:00:00 2001 From: Diana <40689028+ausiejute@users.noreply.github.com> Date: Wed, 21 Oct 2026 15:12:19 +0100 Subject: [PATCH 5/5] Add the console.log line back in --- dead-code/exercise-2.js | 1 + 1 file changed, 1 insertion(+) diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index 4537a4dbbf..bdfb57aaf0 100644 --- a/dead-code/exercise-2.js +++ b/dead-code/exercise-2.js @@ -20,3 +20,4 @@ function countAndCapitalisePets(petsArr) { } const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); +console.log(countedPetsStartingWithH);