Skip to content

Commit af2b948

Browse files
committed
removing dead code
1 parent 3e09a68 commit af2b948

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
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 greeting = "hello";
4+
const greeting = "hello";
55

66
function sayHello(greeting, name) {
7-
const greetingStr = greeting + ", " + name + "!";
87
return `${greeting}, ${name}!`;
9-
console.log(greetingStr);
108
}
119

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
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

87
function countAndCapitalisePets(petsArr) {
@@ -19,4 +18,5 @@ function countAndCapitalisePets(petsArr) {
1918
return petCount;
2019
}
2120

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

0 commit comments

Comments
 (0)