From d5fd15c7a1c9b268a0e2ad64f31b7f70afa7889f Mon Sep 17 00:00:00 2001 From: abmhts Date: Tue, 20 Oct 2026 10:39:46 +0100 Subject: [PATCH 1/3] Removed unreachable and redundant code --- 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 3e4034fc00944589f7c98141c8d9adc34e96f839 Mon Sep 17 00:00:00 2001 From: abmhts Date: Tue, 20 Oct 2026 11:22:46 +0100 Subject: [PATCH 2/3] Removed the unused code --- dead-code/exercise-2.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index 56d7887c4c..1d292f2f8c 100644 --- a/dead-code/exercise-2.js +++ b/dead-code/exercise-2.js @@ -2,12 +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)); -} +const petsStartingWithH = pets.filter((pet) => pet[0] === "h"); function countAndCapitalisePets(petsArr) { const petCount = {}; From 85f49fdeb4a0d3779d6411ef928b1d89929bab4d Mon Sep 17 00:00:00 2001 From: abmhts Date: Wed, 21 Oct 2026 16:05:37 +0100 Subject: [PATCH 3/3] update - removed redundant code --- dead-code/exercise-1.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index 5de7eb4ba7..b2ddd4e039 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,15 +1,8 @@ // 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}!`; } -testName = "Aman"; - -const greetingMessage = sayHello(greeting, testName); - -console.log(greetingMessage); // 'hello, Aman!' +console.log(sayHello("hello", "Aman"));