Skip to content

Commit 3e09a68

Browse files
committed
fixing a dead code
1 parent b31a586 commit 3e09a68

2 files changed

Lines changed: 3 additions & 14 deletions

File tree

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +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";
5-
const greeting = "hello";
4+
let greeting = "hello";
65

76
function sayHello(greeting, name) {
87
const greetingStr = greeting + ", " + name + "!";
98
return `${greeting}, ${name}!`;
109
console.log(greetingStr);
1110
}
1211

13-
testName = "Aman";
14-
15-
const greetingMessage = sayHello(greeting, testName);
16-
17-
console.log(greetingMessage); // 'hello, Aman!'
12+
console.log(sayHello(greeting, "Aman")); // 'hello, Aman!'

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@ const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"];
55
const capitalisedPets = pets.map((pet) => pet.toUpperCase());
66
const petsStartingWithH = pets.filter((pet) => pet[0] === "h");
77

8-
function logPets(petsArr) {
9-
petsArr.forEach((pet) => console.log(pet));
10-
}
11-
128
function countAndCapitalisePets(petsArr) {
139
const petCount = {};
1410

@@ -23,6 +19,4 @@ function countAndCapitalisePets(petsArr) {
2319
return petCount;
2420
}
2521

26-
const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH);
27-
28-
console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log
22+
console.log(countAndCapitalisePets(petsStartingWithH)); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log

0 commit comments

Comments
 (0)