From d71e824ea53b2909814fda89beef1f1f0576e0c8 Mon Sep 17 00:00:00 2001 From: SalahAlsabhi Date: Wed, 21 Oct 2026 16:48:21 +0100 Subject: [PATCH] Remove dead code from exercise-1 and exercise-2 --- dead-code/exercise-1.js | 10 +--------- dead-code/exercise-2.js | 4 ---- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/dead-code/exercise-1.js b/dead-code/exercise-1.js index 4d09f15fa..69f177bf6 100644 --- a/dead-code/exercise-1.js +++ b/dead-code/exercise-1.js @@ -1,17 +1,9 @@ // 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"; - function sayHello(greeting, name) { - const greetingStr = greeting + ", " + name + "!"; return `${greeting}, ${name}!`; - console.log(greetingStr); } -testName = "Aman"; - -const greetingMessage = sayHello(greeting, testName); +console.log(sayHello("hello", "Aman")); // 'hello, Aman!' -console.log(greetingMessage); // 'hello, Aman!' diff --git a/dead-code/exercise-2.js b/dead-code/exercise-2.js index 56d7887c4..eecc0d358 100644 --- a/dead-code/exercise-2.js +++ b/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)); -} function countAndCapitalisePets(petsArr) { const petCount = {};