From 37469e65b97f9cfa9484ce9b1c3ecf30024b0030 Mon Sep 17 00:00:00 2001 From: Shirin Panahian Date: Thu, 22 Oct 2026 22:09:26 +0100 Subject: [PATCH 1/3] Remove unreachable and redundant code from sayHello --- dead-code/exercise-1.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index 4d09f15fa9..aad02f28e8 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,17 +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. - -let testName = "Jerry"; +const personName = "Aman"; 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!' +console.log(sayHello(greeting, personName)); // 'hello, Aman!' From ca0f2885a03b4cffc7b15aeb4a9f9f0600a7e5f6 Mon Sep 17 00:00:00 2001 From: Shirin Panahian Date: Thu, 22 Oct 2026 22:11:40 +0100 Subject: [PATCH 2/3] Remove unused pet processing code --- 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 765fc43270927081afdb747e1ad12fea26fb5c63 Mon Sep 17 00:00:00 2001 From: Shirin Panahian Date: Fri, 23 Oct 2026 09:41:56 +0100 Subject: [PATCH 3/3] direct parameter --- 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 aad02f28e8..0b85af6f66 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,10 +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. -const personName = "Aman"; -const greeting = "hello"; function sayHello(greeting, name) { return `${greeting}, ${name}!`; } -console.log(sayHello(greeting, personName)); // 'hello, Aman!' +console.log(sayHello("hello", "Aman")); // 'hello, Aman!'