From 3e09a685564894e55b9e1973c72f68231eec365e Mon Sep 17 00:00:00 2001 From: abduhasen Date: Mon, 13 Jul 2026 12:05:57 +0100 Subject: [PATCH 1/2] fixing a dead code --- Sprint-3/3-dead-code/exercise-1.js | 9 ++------- Sprint-3/3-dead-code/exercise-2.js | 8 +------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index 4d09f15fa9..88baf667af 100644 --- a/Sprint-3/3-dead-code/exercise-1.js +++ b/Sprint-3/3-dead-code/exercise-1.js @@ -1,8 +1,7 @@ // 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 greeting = "hello"; function sayHello(greeting, name) { const greetingStr = greeting + ", " + name + "!"; @@ -10,8 +9,4 @@ function sayHello(greeting, name) { console.log(greetingStr); } -testName = "Aman"; - -const greetingMessage = sayHello(greeting, testName); - -console.log(greetingMessage); // 'hello, Aman!' +console.log(sayHello(greeting, "Aman")); // 'hello, Aman!' diff --git a/Sprint-3/3-dead-code/exercise-2.js b/Sprint-3/3-dead-code/exercise-2.js index 56d7887c4c..a8dda13e86 100644 --- a/Sprint-3/3-dead-code/exercise-2.js +++ b/Sprint-3/3-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 = {}; @@ -23,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 af2b948683c128ab5fc33541848b1e8bb0052ad2 Mon Sep 17 00:00:00 2001 From: abduhasen Date: Mon, 20 Jul 2026 15:55:51 +0100 Subject: [PATCH 2/2] removing dead code --- Sprint-3/3-dead-code/exercise-1.js | 10 ++++++---- Sprint-3/3-dead-code/exercise-2.js | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index 88baf667af..e51f0e5871 100644 --- a/Sprint-3/3-dead-code/exercise-1.js +++ b/Sprint-3/3-dead-code/exercise-1.js @@ -1,12 +1,14 @@ // 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 greeting = "hello"; +const greeting = "hello"; function sayHello(greeting, name) { - const greetingStr = greeting + ", " + name + "!"; return `${greeting}, ${name}!`; - console.log(greetingStr); } -console.log(sayHello(greeting, "Aman")); // 'hello, Aman!' +testName = "Aman"; + +const greetingMessage = sayHello(greeting, testName); + +console.log(greetingMessage); // 'hello, Aman!' diff --git a/Sprint-3/3-dead-code/exercise-2.js b/Sprint-3/3-dead-code/exercise-2.js index a8dda13e86..7eb1e16bef 100644 --- a/Sprint-3/3-dead-code/exercise-2.js +++ b/Sprint-3/3-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) { @@ -19,4 +18,5 @@ function countAndCapitalisePets(petsArr) { return petCount; } +const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); console.log(countAndCapitalisePets(petsStartingWithH)); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log