From c6e9e7bcdea0722cc80624a55382e3fe1c83923e Mon Sep 17 00:00:00 2001 From: anitahy73 Date: Sun, 26 Jul 2026 17:04:35 +0100 Subject: [PATCH 1/3] Refactor sayHello function and clean up code Removed unreachable code and updated testName variable. --- Sprint-3/3-dead-code/exercise-1.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index 4d09f15fa9..e453450b9a 100644 --- a/Sprint-3/3-dead-code/exercise-1.js +++ b/Sprint-3/3-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"; +let testName = "Aman"; const greeting = "hello"; function sayHello(greeting, name) { - const greetingStr = greeting + ", " + name + "!"; - return `${greeting}, ${name}!`; - console.log(greetingStr); + return ${greeting}, ${name}!; } -testName = "Aman"; - const greetingMessage = sayHello(greeting, testName); console.log(greetingMessage); // 'hello, Aman!' From 85c1c840a60e8f3f55d24fcb40a51a84602527bf Mon Sep 17 00:00:00 2001 From: anitahy73 Date: Sun, 26 Jul 2026 17:05:14 +0100 Subject: [PATCH 2/3] Clean up dead code in exercise-2.js Removed unused code and a function that was not contributing to the final output. --- Sprint-3/3-dead-code/exercise-2.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-2.js b/Sprint-3/3-dead-code/exercise-2.js index 56d7887c4c..b1c2362d34 100644 --- a/Sprint-3/3-dead-code/exercise-2.js +++ b/Sprint-3/3-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 3fc30ba32f09e3f299843440bd97e5d3a55a2cae Mon Sep 17 00:00:00 2001 From: anitahy73 Date: Sat, 1 Aug 2026 15:15:00 +0100 Subject: [PATCH 3/3] Revert changes --- Sprint-3/3-dead-code/exercise-1.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index e453450b9a..4d09f15fa9 100644 --- a/Sprint-3/3-dead-code/exercise-1.js +++ b/Sprint-3/3-dead-code/exercise-1.js @@ -1,13 +1,17 @@ // 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 = "Aman"; +let testName = "Jerry"; const greeting = "hello"; function sayHello(greeting, name) { - return ${greeting}, ${name}!; + const greetingStr = greeting + ", " + name + "!"; + return `${greeting}, ${name}!`; + console.log(greetingStr); } +testName = "Aman"; + const greetingMessage = sayHello(greeting, testName); console.log(greetingMessage); // 'hello, Aman!'