From 8e662d16b54ad2147817faf0114918a6a123ef4f Mon Sep 17 00:00:00 2001 From: Hanna Bohlin Date: Mon, 26 Oct 2026 17:18:39 +0000 Subject: [PATCH 1/3] Remove 3 lines of dead code, 2 in function and one unused variable declaration and declared it elsewhere --- dead-code/exercise-1.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index 4d09f15fa9..a16daa17b8 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,16 +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 greeting = "hello"; function sayHello(greeting, name) { - const greetingStr = greeting + ", " + name + "!"; return `${greeting}, ${name}!`; - console.log(greetingStr); } -testName = "Aman"; +const testName = "Aman"; const greetingMessage = sayHello(greeting, testName); From 16fd29e58721055d12acb0c7199d3f498bae3c9f Mon Sep 17 00:00:00 2001 From: Hanna Bohlin Date: Mon, 26 Oct 2026 17:27:09 +0000 Subject: [PATCH 2/3] Remove capitalised pets that was unused, and function to print pets that was never called --- dead-code/exercise-2.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index 56d7887c4c..b1c2362d34 100644 --- a/dead-code/exercise-2.js +++ b/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()); const petsStartingWithH = pets.filter((pet) => pet[0] === "h"); -function logPets(petsArr) { - petsArr.forEach((pet) => console.log(pet)); -} - function countAndCapitalisePets(petsArr) { const petCount = {}; From 652c4a98bc614ff2e75b4cdcc0a772f4bf858e05 Mon Sep 17 00:00:00 2001 From: Hanna Bohlin Date: Wed, 28 Oct 2026 13:54:33 +0000 Subject: [PATCH 3/3] Removing variables and adding arguments inline on function call --- dead-code/exercise-1.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index a16daa17b8..db6e4eb856 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,14 +1,10 @@ // Find the instances of unreachable and redundant code - remove them! // The sayHello function should continue to work for any reasonable input it's given. -const greeting = "hello"; - function sayHello(greeting, name) { return `${greeting}, ${name}!`; } -const testName = "Aman"; - -const greetingMessage = sayHello(greeting, testName); +const greetingMessage = sayHello("hello", "Aman"); console.log(greetingMessage); // 'hello, Aman!'