From f784a8bdb23ba3861f57f51bbcea855e7742a965 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Mon, 19 Oct 2026 17:04:47 +0100 Subject: [PATCH 1/5] Removed the "let testName = "Jerry" as it isn't required at all in this code. removed console.log(greetingStr) as the return stops the function and never reaches that consol.log. Cleaned up the code as it doing the same request twice in it. --- dead-code/exercise-1.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index 4d09f15fa9..f5a4fe1ead 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,17 +1,22 @@ // 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"; +// let testName = "Jerry"; +// const greeting = "hello"; -function sayHello(greeting, name) { - const greetingStr = greeting + ", " + name + "!"; - return `${greeting}, ${name}!`; - console.log(greetingStr); -} +// function sayHello(greeting, name) { +// const greetingStr = greeting + ", " + name + "!"; +// return `${greeting}, ${name}!`; +// console.log(greetingStr); +// } + +// testName = "Aman"; -testName = "Aman"; +// const greetingMessage = sayHello(greeting, testName); -const greetingMessage = sayHello(greeting, testName); +// console.log(greetingMessage); // 'hello, Aman!' -console.log(greetingMessage); // 'hello, Aman!' +function sayHello(greeting, name) { + return `${greeting}, ${name}!`; +} +console.log(sayHello("hello", "Aman")); // 'hello, Aman!' From 9d51d5de99644072a0a515fd41bc0a7ae9360e98 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Mon, 19 Oct 2026 17:05:31 +0100 Subject: [PATCH 2/5] removed the older code and other // comments --- dead-code/exercise-1.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index f5a4fe1ead..f4f33a9c51 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,21 +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!' - function sayHello(greeting, name) { return `${greeting}, ${name}!`; } From a98f697d02024b6ecdd9e11a92e3f71ab6d5dbd7 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Mon, 19 Oct 2026 17:05:58 +0100 Subject: [PATCH 3/5] small cleanup --- dead-code/exercise-1.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index f4f33a9c51..005cbc360f 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -4,4 +4,5 @@ function sayHello(greeting, name) { return `${greeting}, ${name}!`; } -console.log(sayHello("hello", "Aman")); // 'hello, Aman!' +// 'hello, Aman!' +console.log(sayHello("hello", "Aman")); From b41f635eae1bee01d285d5c1a855db2494e63d84 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Mon, 19 Oct 2026 17:09:30 +0100 Subject: [PATCH 4/5] removed capitalisedPets, its not called anywhere. Removed function logPets for same reason --- dead-code/exercise-2.js | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index 56d7887c4c..4ac310a1e0 100644 --- a/dead-code/exercise-2.js +++ b/dead-code/exercise-2.js @@ -1,14 +1,35 @@ // Remove the unused code that does not contribute to the final console log // 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 = {}; + +// petsArr.forEach((pet) => { +// const capitalisedPet = pet.toUpperCase(); +// if (petCount[capitalisedPet]) { +// petCount[capitalisedPet] += 1; +// } else { +// petCount[capitalisedPet] = 1; +// } +// }); +// return petCount; +// } + +// const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); + +// console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log + 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 4e98905b434762bfe0567e25f7462ec6b611e145 Mon Sep 17 00:00:00 2001 From: HM-127BTY Date: Wed, 21 Oct 2026 13:31:22 +0100 Subject: [PATCH 5/5] removed some lines of code as they felt like they were not needed. --- dead-code/exercise-2.js | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index 4ac310a1e0..b1c2362d34 100644 --- a/dead-code/exercise-2.js +++ b/dead-code/exercise-2.js @@ -1,32 +1,6 @@ // Remove the unused code that does not contribute to the final console log // 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 = {}; - -// petsArr.forEach((pet) => { -// const capitalisedPet = pet.toUpperCase(); -// if (petCount[capitalisedPet]) { -// petCount[capitalisedPet] += 1; -// } else { -// petCount[capitalisedPet] = 1; -// } -// }); -// return petCount; -// } - -// const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); - -// console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log - const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"]; const petsStartingWithH = pets.filter((pet) => pet[0] === "h");