From 05cbf4945f08e4beea1a9211921ce65108d3f043 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Fri, 16 Oct 2026 09:36:14 +0200 Subject: [PATCH 1/9] Moved return to the end of function --- dead-code/exercise-1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index 4d09f15fa9..3b5d290992 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -6,8 +6,8 @@ const greeting = "hello"; function sayHello(greeting, name) { const greetingStr = greeting + ", " + name + "!"; - return `${greeting}, ${name}!`; console.log(greetingStr); + return `${greeting}, ${name}!`; } testName = "Aman"; From 44c2ce31b6753651e5d9279123f981b4c75c58c6 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Fri, 16 Oct 2026 10:13:59 +0200 Subject: [PATCH 2/9] Removed extra console.log() inside function and removed redundant greeting declaration --- 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 3b5d290992..346be731b0 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,17 +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"; +let testName = "Aman"; function sayHello(greeting, name) { - const greetingStr = greeting + ", " + name + "!"; - console.log(greetingStr); return `${greeting}, ${name}!`; } -testName = "Aman"; - const greetingMessage = sayHello(greeting, testName); console.log(greetingMessage); // 'hello, Aman!' From a7912d7dadae23f269a967802008e54709b56757 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Fri, 16 Oct 2026 10:15:50 +0200 Subject: [PATCH 3/9] Added function call inside console.log() outside function and removed unnecesarry var declaration --- 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 346be731b0..35cf4c3f0f 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -8,6 +8,4 @@ function sayHello(greeting, name) { return `${greeting}, ${name}!`; } -const greetingMessage = sayHello(greeting, testName); - -console.log(greetingMessage); // 'hello, Aman!' +console.log(sayHello(greeting, testName)); // 'hello, Aman!' From 28dd01060ffb6cf02fdb64e550322729cd2eef1e Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Fri, 16 Oct 2026 10:17:39 +0200 Subject: [PATCH 4/9] Added actual values instead of variables inside function call. It should be able to still take any reasonable input --- 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 35cf4c3f0f..0b85af6f66 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,11 +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 greeting = "hello"; -let testName = "Aman"; - function sayHello(greeting, name) { return `${greeting}, ${name}!`; } -console.log(sayHello(greeting, testName)); // 'hello, Aman!' +console.log(sayHello("hello", "Aman")); // 'hello, Aman!' From e75ac489c0040e8121c32745b52d7c86170ffc27 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Fri, 16 Oct 2026 10:33:01 +0200 Subject: [PATCH 5/9] Remove redundant function logPets() --- 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 56d7887c4c..6cd58f1dd7 100644 --- a/dead-code/exercise-2.js +++ b/dead-code/exercise-2.js @@ -5,10 +5,6 @@ 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 77d2d375824cf7ca1a12d25ba2ff8a1c1893017a Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Fri, 16 Oct 2026 10:36:06 +0200 Subject: [PATCH 6/9] Add function call inside console.log() and remove unecessary var declaration --- dead-code/exercise-2.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index 6cd58f1dd7..a8dda13e86 100644 --- a/dead-code/exercise-2.js +++ b/dead-code/exercise-2.js @@ -19,6 +19,4 @@ function countAndCapitalisePets(petsArr) { return petCount; } -const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); - -console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log +console.log(countAndCapitalisePets(petsStartingWithH)); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log From f64f9fee49502703865221202f229fdc2d8204b0 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Fri, 16 Oct 2026 10:42:29 +0200 Subject: [PATCH 7/9] Remove capitalisedPets code because it already happens inside or function --- dead-code/exercise-2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index a8dda13e86..03d1641dfa 100644 --- a/dead-code/exercise-2.js +++ b/dead-code/exercise-2.js @@ -2,7 +2,7 @@ // 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 capitalisedPets = pets.map((pet) => pet.toUpperCase()); const petsStartingWithH = pets.filter((pet) => pet[0] === "h"); function countAndCapitalisePets(petsArr) { From 9053cec56d10e09eb54ea11e6215e4e448993ce0 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Fri, 16 Oct 2026 10:42:43 +0200 Subject: [PATCH 8/9] Remove capitalisedPets code because it already happens inside or function --- 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 03d1641dfa..443c0345c3 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 countAndCapitalisePets(petsArr) { From 30864f3a10bbe7b6c696fa2d40fdb1af6117c667 Mon Sep 17 00:00:00 2001 From: Tyler-leigh Ross Date: Tue, 27 Oct 2026 09:38:31 +0200 Subject: [PATCH 9/9] Added variable back in and pass variable into function call --- dead-code/exercise-1.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index 0b85af6f66..94b8adb7df 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -5,4 +5,6 @@ function sayHello(greeting, name) { return `${greeting}, ${name}!`; } -console.log(sayHello("hello", "Aman")); // 'hello, Aman!' +let testName = "Aman" + +console.log(sayHello("hello", testName));