Skip to content

Commit b2e6999

Browse files
committed
remove dead code from exercises
1 parent 29ef74a commit b2e6999

2 files changed

Lines changed: 3 additions & 17 deletions

File tree

‎dead-code/exercise-1.js‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
// Find the instances of unreachable and redundant code - remove them!
2-
// The sayHello function should continue to work for any reasonable input it's given.
3-
4-
let testName = "Jerry";
51
const greeting = "hello";
62

73
function sayHello(greeting, name) {
8-
const greetingStr = greeting + ", " + name + "!";
94
return `${greeting}, ${name}!`;
10-
console.log(greetingStr);
115
}
126

13-
testName = "Aman";
7+
let testName = "Aman";
148

159
const greetingMessage = sayHello(greeting, testName);
1610

17-
console.log(greetingMessage); // 'hello, Aman!'
11+
console.log(greetingMessage);

‎dead-code/exercise-2.js‎

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
1-
// Remove the unused code that does not contribute to the final console log
2-
// The countAndCapitalisePets function should continue to work for any reasonable input it's given, and you shouldn't modify the pets variable.
3-
41
const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"];
5-
const capitalisedPets = pets.map((pet) => pet.toUpperCase());
62
const petsStartingWithH = pets.filter((pet) => pet[0] === "h");
73

8-
function logPets(petsArr) {
9-
petsArr.forEach((pet) => console.log(pet));
10-
}
11-
124
function countAndCapitalisePets(petsArr) {
135
const petCount = {};
146

@@ -25,4 +17,4 @@ function countAndCapitalisePets(petsArr) {
2517

2618
const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH);
2719

28-
console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log
20+
console.log(countedPetsStartingWithH);

0 commit comments

Comments
 (0)