Skip to content

Commit 020503b

Browse files
committed
removed dead and unreachable code from the 2 files
1 parent 29ef74a commit 020503b

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

‎dead-code/exercise-1.js‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
// Find the instances of unreachable and redundant code - remove them!
22
// The sayHello function should continue to work for any reasonable input it's given.
33

4-
let testName = "Jerry";
54
const greeting = "hello";
5+
const testName = "Aman";
66

77
function sayHello(greeting, name) {
8-
const greetingStr = greeting + ", " + name + "!";
8+
99
return `${greeting}, ${name}!`;
10-
console.log(greetingStr);
10+
1111
}
1212

13-
testName = "Aman";
1413

1514
const greetingMessage = sayHello(greeting, testName);
1615

‎dead-code/exercise-2.js‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22
// The countAndCapitalisePets function should continue to work for any reasonable input it's given, and you shouldn't modify the pets variable.
33

44
const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"];
5-
const capitalisedPets = pets.map((pet) => pet.toUpperCase());
6-
const petsStartingWithH = pets.filter((pet) => pet[0] === "h");
75

8-
function logPets(petsArr) {
9-
petsArr.forEach((pet) => console.log(pet));
10-
}
6+
const petsStartingWithH = pets.filter((pet) => pet[0] === "h");
117

128
function countAndCapitalisePets(petsArr) {
139
const petCount = {};
@@ -20,9 +16,8 @@ function countAndCapitalisePets(petsArr) {
2016
petCount[capitalisedPet] = 1;
2117
}
2218
});
23-
return petCount;
19+
return petCount;
2420
}
25-
2621
const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH);
2722

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

0 commit comments

Comments
 (0)