From 55d992aac05b8bf1013a56c74dd11ff3c99a7a96 Mon Sep 17 00:00:00 2001 From: Alina Sofragiu Date: Sat, 4 Jul 2026 18:32:10 +0100 Subject: [PATCH 1/2] dead code --- Sprint-3/3-dead-code/exercise-1.js | 2 -- Sprint-3/3-dead-code/exercise-2.js | 9 +++------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index 4d09f15fa9..5de7eb4ba7 100644 --- a/Sprint-3/3-dead-code/exercise-1.js +++ b/Sprint-3/3-dead-code/exercise-1.js @@ -5,9 +5,7 @@ let testName = "Jerry"; const greeting = "hello"; function sayHello(greeting, name) { - const greetingStr = greeting + ", " + name + "!"; return `${greeting}, ${name}!`; - console.log(greetingStr); } testName = "Aman"; diff --git a/Sprint-3/3-dead-code/exercise-2.js b/Sprint-3/3-dead-code/exercise-2.js index 56d7887c4c..538f9ae4cc 100644 --- a/Sprint-3/3-dead-code/exercise-2.js +++ b/Sprint-3/3-dead-code/exercise-2.js @@ -2,12 +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)); -} +const petsStartingWithH = pets.filter((pet) => pet[0] === "h"); function countAndCapitalisePets(petsArr) { const petCount = {}; @@ -20,9 +16,10 @@ function countAndCapitalisePets(petsArr) { petCount[capitalisedPet] = 1; } }); + return petCount; } const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); -console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log +console.log(countedPetsStartingWithH); // { HAMSTER: 3, HORSE: 1 } From e53ca25cfe73a7f80bad6aef9c74f40995fc2e9a Mon Sep 17 00:00:00 2001 From: sofragiualina Date: Thu, 9 Jul 2026 12:11:09 +0100 Subject: [PATCH 2/2] Refactor testName variable in exercise-1.js Updated testName variable to use 'Aman' instead of 'Jerry'. --- Sprint-3/3-dead-code/exercise-1.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index 5de7eb4ba7..946bb198de 100644 --- a/Sprint-3/3-dead-code/exercise-1.js +++ b/Sprint-3/3-dead-code/exercise-1.js @@ -1,14 +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) { return `${greeting}, ${name}!`; } -testName = "Aman"; const greetingMessage = sayHello(greeting, testName);