From 59b0c407d2efe6d7b819f9f2a9cb8f8ac7f95643 Mon Sep 17 00:00:00 2001 From: Carlos Abreu Date: Wed, 4 Mar 2026 21:48:46 +0000 Subject: [PATCH 1/5] .gitignore add package.json and package-lock.json committed --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index bde36e5302..ed63450dce 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ node_modules .DS_Store .vscode -**/.DS_Store \ No newline at end of file +*package.json +*package-lock.json +**/.DS_Store From 84a56addb5ad9ee09ef8e8581fd9b3c21a49b258 Mon Sep 17 00:00:00 2001 From: Carlos Abreu Date: Wed, 4 Mar 2026 21:49:42 +0000 Subject: [PATCH 2/5] refactored and cleaned dead code --- Sprint-3/3-dead-code/exercise-1.js | 22 +++++++++++++++++++++ Sprint-3/3-dead-code/exercise-2.js | 31 ++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index 4d09f15fa9..a199ca65a1 100644 --- a/Sprint-3/3-dead-code/exercise-1.js +++ b/Sprint-3/3-dead-code/exercise-1.js @@ -1,3 +1,6 @@ +/** + * Original code: + * // Find the instances of unreachable and redundant code - remove them! // The sayHello function should continue to work for any reasonable input it's given. @@ -15,3 +18,22 @@ testName = "Aman"; const greetingMessage = sayHello(greeting, testName); console.log(greetingMessage); // 'hello, Aman!' +* +* End of code +*/ + +// The sayHello function should continue to work for any reasonable input it's given. + +let testName = "Jerry"; +const greeting = "hello"; + +function sayHello(greeting, name) { + return `${greeting}, ${name}!`; +} + +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 56d7887c4c..c647653aed 100644 --- a/Sprint-3/3-dead-code/exercise-2.js +++ b/Sprint-3/3-dead-code/exercise-2.js @@ -1,3 +1,6 @@ +/** + * Original file: + * // Remove the unused code that does not contribute to the final console log // The countAndCapitalisePets function should continue to work for any reasonable input it's given, and you shouldn't modify the pets variable. @@ -26,3 +29,31 @@ function countAndCapitalisePets(petsArr) { const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log +* +* End of file +*/ + +// Remove the unused code that does not contribute to the final console log +// 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 petsStartingWithH = pets.filter((pet) => pet[0] === "h"); + +function countAndCapitalisePets(petsArr) { + const petCount = {}; + + petsArr.forEach((pet) => { + const capitalisedPet = pet.toUpperCase(); + if (petCount[capitalisedPet]) { + petCount[capitalisedPet] += 1; + } else { + petCount[capitalisedPet] = 1; + } + }); + return petCount; +} + +const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); + +console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log + From b55668e835d0e45bb6ee0113ada4237067c89f33 Mon Sep 17 00:00:00 2001 From: Carlos Abreu Date: Mon, 16 Mar 2026 22:57:20 +0000 Subject: [PATCH 3/5] Removed the olde code --- Sprint-3/3-dead-code/exercise-1.js | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-1.js b/Sprint-3/3-dead-code/exercise-1.js index a199ca65a1..06f36b1ab2 100644 --- a/Sprint-3/3-dead-code/exercise-1.js +++ b/Sprint-3/3-dead-code/exercise-1.js @@ -1,26 +1,3 @@ -/** - * Original code: - * -// 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(greetingMessage); // 'hello, Aman!' -* -* End of code -*/ // The sayHello function should continue to work for any reasonable input it's given. From 44135e301b9bbbe29d73ffd8f25aecad1720667c Mon Sep 17 00:00:00 2001 From: Carlos Abreu Date: Mon, 16 Mar 2026 22:59:03 +0000 Subject: [PATCH 4/5] Deleted the old code --- Sprint-3/3-dead-code/exercise-2.js | 34 ------------------------------ 1 file changed, 34 deletions(-) diff --git a/Sprint-3/3-dead-code/exercise-2.js b/Sprint-3/3-dead-code/exercise-2.js index c647653aed..1d153bbb7c 100644 --- a/Sprint-3/3-dead-code/exercise-2.js +++ b/Sprint-3/3-dead-code/exercise-2.js @@ -1,37 +1,3 @@ -/** - * Original file: - * -// Remove the unused code that does not contribute to the final console log -// 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 = {}; - - petsArr.forEach((pet) => { - const capitalisedPet = pet.toUpperCase(); - if (petCount[capitalisedPet]) { - petCount[capitalisedPet] += 1; - } else { - petCount[capitalisedPet] = 1; - } - }); - return petCount; -} - -const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH); - -console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log -* -* End of file -*/ // Remove the unused code that does not contribute to the final console log // The countAndCapitalisePets function should continue to work for any reasonable input it's given, and you shouldn't modify the pets variable. From 56021d5f08236d58d22b34357be82b70fbc01697 Mon Sep 17 00:00:00 2001 From: Carlos Abreu Date: Mon, 16 Mar 2026 23:07:02 +0000 Subject: [PATCH 5/5] Deleted package.json and package-lock.json entry in gitignore --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index ed63450dce..98304d724a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ node_modules .DS_Store .vscode -*package.json -*package-lock.json **/.DS_Store