Skip to content

Commit 030780f

Browse files
committed
removed the dead code for sprint 3 dead code tasks
1 parent 49fe3af commit 030780f

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
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";
4+
let testName = "Aman";
55
const greeting = "hello";
66

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

1312
testName = "Aman";

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +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());
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 = {};
1410

1511
petsArr.forEach((pet) => {
1612
const capitalisedPet = pet.toUpperCase();
13+
1714
if (petCount[capitalisedPet]) {
1815
petCount[capitalisedPet] += 1;
16+
1917
} else {
2018
petCount[capitalisedPet] = 1;
2119
}
20+
2221
});
22+
2323
return petCount;
2424
}
2525

0 commit comments

Comments
 (0)