From 2dbf4e5b7ff07688d1ff4cafb86f9f37e3e3f0b3 Mon Sep 17 00:00:00 2001 From: eyob tech Date: Thu, 23 Jul 2026 00:20:51 +0100 Subject: [PATCH 1/2] Remove redundant assignment and unreachable code in exercise-1 --- Sprint-3/3-dead-code/exercise-1.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index 4d09f15fa9..fde27b8263 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!' +console.log(greetingMessage); // 'hello, Aman!' \ No newline at end of file From b29752c38157d500dd11fbe99e356fcaccaa0248 Mon Sep 17 00:00:00 2001 From: eyob tech Date: Thu, 23 Jul 2026 00:21:11 +0100 Subject: [PATCH 2/2] Remove unused function and variable in exercise-2 --- Sprint-3/3-dead-code/exercise-2.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-2.js b/Sprint-3/3-dead-code/exercise-2.js index 56d7887c4c..e83c7bf082 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 = {}; @@ -25,4 +20,4 @@ function countAndCapitalisePets(petsArr) { const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); -console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log +console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log \ No newline at end of file