Skip to content

Commit 4a3e851

Browse files
committed
exercise 2
1 parent f3378b3 commit 4a3e851

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
// Remove the unused code that does not contribute to the final console log
22
// The countAndCapitalisePets function should continue to work for any reasonable input it's given, and you shouldn't modify the pets variable.
33

4+
45
const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"];
5-
const capitalisedPets = pets.map((pet) => pet.toUpperCase());
6+
// const capitalisedPets = pets.map((pet) => pet.toUpperCase()); - redundant
67
const petsStartingWithH = pets.filter((pet) => pet[0] === "h");
78

8-
function logPets(petsArr) {
9-
petsArr.forEach((pet) => console.log(pet));
10-
}
9+
10+
// function logPets(petsArr) {
11+
// petsArr.forEach((pet) => console.log(pet));
12+
// } - redundant
13+
1114

1215
function countAndCapitalisePets(petsArr) {
1316
const petCount = {};
@@ -23,6 +26,9 @@ function countAndCapitalisePets(petsArr) {
2326
return petCount;
2427
}
2528

29+
2630
const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH);
2731

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

0 commit comments

Comments
 (0)