Skip to content

Commit 052c3a9

Browse files
committed
prettier-ified all files
1 parent 2547e09 commit 052c3a9

File tree

3 files changed

+29
-34
lines changed

3 files changed

+29
-34
lines changed

Sprint-3/dead-code/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@ Here are two example of code that has not been built efficiently. Both files hav
55
## Instructions
66

77
1. Work through each `exercise` file inside this directory.
8-
2. Delete the dead code.
9-
3. Commit your changes and make a PR when done.
10-
11-
8+
2. Delete the dead code.
9+
3. Commit your changes and make a PR when done.

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
// Find the instances of unreachable and redundant code - remove them!
22

3-
let testName = 'Jerry'
4-
const greeting = 'hello'
3+
let testName = "Jerry";
4+
const greeting = "hello";
55

66
function sayHello(greeting, name) {
7-
const greetingStr = greeting + ', ' + name + '!'
8-
return `${greeting}, ${name}!`
9-
console.log(greetingStr)
10-
}
11-
12-
testName = 'Aman'
13-
14-
const greetingMessage = sayHello(greeting, testName)
15-
16-
console.log(greetingMessage) // 'hello, Aman!'
7+
const greetingStr = greeting + ", " + name + "!";
8+
return `${greeting}, ${name}!`;
9+
console.log(greetingStr);
10+
}
1711

12+
testName = "Aman";
1813

14+
const greetingMessage = sayHello(greeting, testName);
1915

16+
console.log(greetingMessage); // 'hello, Aman!'

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
// Remove the unused code that does not contribute to the final console log
22

3-
const pets = ['parrot', 'hamster', 'horse', 'dog', 'hamster','cat', 'hamster']
4-
const capitalisedPets = pets.map((pet) => pet.toUpperCase())
5-
const petsStartingWithH = pets.filter((pet) => pet[0] === 'h')
3+
const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"];
4+
const capitalisedPets = pets.map((pet) => pet.toUpperCase());
5+
const petsStartingWithH = pets.filter((pet) => pet[0] === "h");
66

7-
function logPets(petsArr){
8-
petsArr.forEach((pet) => console.log(pet))
7+
function logPets(petsArr) {
8+
petsArr.forEach((pet) => console.log(pet));
99
}
1010

11-
function countAndCapitalisePets(petsArr){
12-
const petCount = {}
11+
function countAndCapitalisePets(petsArr) {
12+
const petCount = {};
1313

14-
petsArr.forEach((pet) => {
15-
const capitalisedPet = pet.toUpperCase()
16-
if(petCount[capitalisedPet]){
17-
petCount[capitalisedPet] += 1
18-
} else {
19-
petCount[capitalisedPet] = 1
20-
}
21-
})
22-
return petCount
14+
petsArr.forEach((pet) => {
15+
const capitalisedPet = pet.toUpperCase();
16+
if (petCount[capitalisedPet]) {
17+
petCount[capitalisedPet] += 1;
18+
} else {
19+
petCount[capitalisedPet] = 1;
20+
}
21+
});
22+
return petCount;
2323
}
2424

25-
const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH)
25+
const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH);
2626

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

0 commit comments

Comments
 (0)