Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
node_modules
.DS_Store
.vscode
**/.DS_Store
*package.json
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package.json and package-lock.json should not be in gitignore
Also, will *package.json ignore only one type of filename?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Evening @SlideGauge
Thank for the feedback.
I remove the old code on the implementation and made it more cleaner.
Thanks for info not to include package.json and package-lock.json file in .gitignore.
I didn't know that.
About the last question, package.json when put in .gitignore fiel will ignore any files that end with package.json. In other words all files () with suffixes package.json

*package-lock.json
**/.DS_Store
22 changes: 22 additions & 0 deletions Sprint-3/3-dead-code/exercise-1.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Original code:
*
// Find the instances of unreachable and redundant code - remove them!
// The sayHello function should continue to work for any reasonable input it's given.

Expand All @@ -15,3 +18,22 @@ testName = "Aman";
const greetingMessage = sayHello(greeting, testName);

console.log(greetingMessage); // 'hello, Aman!'
*
* End of code
*/

// The sayHello function should continue to work for any reasonable input it's given.

let testName = "Jerry";
const greeting = "hello";

function sayHello(greeting, name) {
return `${greeting}, ${name}!`;
}

testName = "Aman";

const greetingMessage = sayHello(greeting, testName);

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

31 changes: 31 additions & 0 deletions Sprint-3/3-dead-code/exercise-2.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* Original file:
*
// Remove the unused code that does not contribute to the final console log
// The countAndCapitalisePets function should continue to work for any reasonable input it's given, and you shouldn't modify the pets variable.

Expand Down Expand Up @@ -26,3 +29,31 @@ function countAndCapitalisePets(petsArr) {
const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH);

console.log(countedPetsStartingWithH); // { 'HAMSTER': 3, 'HORSE': 1 } <- Final console log
*
* End of file
*/

// Remove the unused code that does not contribute to the final console log
// The countAndCapitalisePets function should continue to work for any reasonable input it's given, and you shouldn't modify the pets variable.

const pets = ["parrot", "hamster", "horse", "dog", "hamster", "cat", "hamster"];
const petsStartingWithH = pets.filter((pet) => pet[0] === "h");

function countAndCapitalisePets(petsArr) {
const petCount = {};

petsArr.forEach((pet) => {
const capitalisedPet = pet.toUpperCase();
if (petCount[capitalisedPet]) {
petCount[capitalisedPet] += 1;
} else {
petCount[capitalisedPet] = 1;
}
});
return petCount;
}

const countedPetsStartingWithH = countAndCapitalisePets(petsStartingWithH);

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

Loading