Skip to content

Commit 4c92134

Browse files
committed
dead-code exercise completed
1 parent 3372770 commit 4c92134

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

Sprint-3/3-dead-code/exercise-1.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ let testName = "Jerry";
55
const greeting = "hello";
66

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

1311
testName = "Aman";

Sprint-3/3-dead-code/exercise-2.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,24 @@
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());
65
const petsStartingWithH = pets.filter((pet) => pet[0] === "h");
76

8-
function logPets(petsArr) {
9-
petsArr.forEach((pet) => console.log(pet));
10-
}
11-
127
function countAndCapitalisePets(petsArr) {
138
const petCount = {};
149

1510
petsArr.forEach((pet) => {
1611
const capitalisedPet = pet.toUpperCase();
12+
1713
if (petCount[capitalisedPet]) {
1814
petCount[capitalisedPet] += 1;
1915
} else {
2016
petCount[capitalisedPet] = 1;
2117
}
2218
});
19+
2320
return petCount;
2421
}
2522

2623
const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH);
2724

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

0 commit comments

Comments
 (0)