From 566310ff8b5fb366ddf3b8391973ff0c0b0b4b46 Mon Sep 17 00:00:00 2001 From: Brian Yorachi Date: Mon, 26 Oct 2026 21:40:26 +0000 Subject: [PATCH 1/4] Remove unused greetingStr and unreachable console.log in exercise-1 --- dead-code/exercise-1.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index 4d09f15fa9..5de7eb4ba7 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -5,9 +5,7 @@ let testName = "Jerry"; const greeting = "hello"; function sayHello(greeting, name) { - const greetingStr = greeting + ", " + name + "!"; return `${greeting}, ${name}!`; - console.log(greetingStr); } testName = "Aman"; From ea267a2ba4c5808a183c59ead10c5ef8e82a340e Mon Sep 17 00:00:00 2001 From: Brian Yorachi Date: Mon, 26 Oct 2026 21:40:36 +0000 Subject: [PATCH 2/4] Remove redundant testName reassignment in exercise-1 --- dead-code/exercise-1.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index 5de7eb4ba7..c92eb0572c 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,15 +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"; +const testName = "Aman"; const greeting = "hello"; function sayHello(greeting, name) { return `${greeting}, ${name}!`; } -testName = "Aman"; - const greetingMessage = sayHello(greeting, testName); console.log(greetingMessage); // 'hello, Aman!' From 36fc1d7cf8aa66de05fae98de52d477c2f0d062d Mon Sep 17 00:00:00 2001 From: Brian Yorachi Date: Mon, 26 Oct 2026 21:43:00 +0000 Subject: [PATCH 3/4] Remove unused capitalisedPets in exercise-2 --- dead-code/exercise-2.js | 1 - 1 file changed, 1 deletion(-) diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index 56d7887c4c..3f54850b3f 100644 --- a/dead-code/exercise-2.js +++ b/dead-code/exercise-2.js @@ -2,7 +2,6 @@ // 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) { From e2fce0708518d5218f77bb086d69a65ea9e9fad2 Mon Sep 17 00:00:00 2001 From: Brian Yorachi Date: Mon, 26 Oct 2026 21:43:15 +0000 Subject: [PATCH 4/4] Remove unused logPets function in exercise-2 --- dead-code/exercise-2.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index 3f54850b3f..b1c2362d34 100644 --- a/dead-code/exercise-2.js +++ b/dead-code/exercise-2.js @@ -4,10 +4,6 @@ const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"]; const petsStartingWithH = pets.filter((pet) => pet[0] === "h"); -function logPets(petsArr) { - petsArr.forEach((pet) => console.log(pet)); -} - function countAndCapitalisePets(petsArr) { const petCount = {};