Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 6 additions & 6 deletions 1-exercises/A-accessing-values/exercise1.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
*/

let dog = {
breed: "Dalmatian",
name: "Spot",
isHungry: true,
happiness: 6
breed: "Dalmatian", // string
name: "Spot", // String
isHungry: true, // Boleean
happiness: 6 // number
};

/*
You can access the values of each property using dot notation.
Log the name and breed of this dog using dot notation.
*/

let dogName; // complete the code
let dogBreed; // complete the code
let dogName = "Spot"; // complete the code
let dogBreed = "Dalmatian"; // complete the code

console.log(`${dogName} is a ${dogBreed}`);

Expand Down
2 changes: 1 addition & 1 deletion 1-exercises/A-accessing-values/exercise2.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let capitalCities = {
*/

let myCountry = "UnitedKingdom";
let myCapitalCity; // complete the code
let myCapitalCity = "London"; // complete the code

console.log(myCapitalCity);

Expand Down
6 changes: 6 additions & 0 deletions 1-exercises/A-accessing-values/exercise3.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ let basketballTeam = {
- sorts the top players in alphabetical order
- console.logs the name of each player on a new line
*/
let alphabetPlayers = basketballTeam.topPlayers.sort()




// write code here
console.log(alphabetPlayers);



/* EXPECTED RESULT
Expand Down
9 changes: 5 additions & 4 deletions 1-exercises/B-setting-values/exercise1.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ let capitalCities = {
name: "Beijing",
}
};

/*
Using dot notation:
- Change the value of UnitedKingdom's capital city population to 8980000.
Expand All @@ -21,17 +20,19 @@ let capitalCities = {
- Add a name of "Lima" to Peru's capital city.
- Add a population of 9750000 to Peru's capital city.
*/

1076382306
// write code here

capitalCities.UnitedKingdom.population = 8980000;
capitalCities.China.population = 21500000;
capitalCities.Peru = {name:"Lima", population : 9750000 };
console.log(capitalCities);

/* EXPECTED RESULT

{
UnitedKingdom: { name: "London", population: 8980000 },
China: { name: "Beijing", population: 21500000 },
Peru: { name: "Lima", population: 9750000 }
Peru: { name: "Lima", population = 9750000 }
}

*/
6 changes: 4 additions & 2 deletions 1-exercises/B-setting-values/exercise2.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let student = {
- Set the value of attendance to 90
*/

// write code here
student["attendance"] = 90;// write code here

/*
- Write an "if" statement that changes the value of hasPassed to true
Expand All @@ -25,7 +25,9 @@ let student = {
- Use bracket notation to change the value of hasPassed
*/

// write code here
if (student["attendance"] >= 90 && student["examScore"] > 60) {
student["hasPassed"] = true;
} // write code here

console.log(student);

Expand Down
6 changes: 3 additions & 3 deletions 1-exercises/C-undefined-properties/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
For each example, can you explain why we are seeing undefined?
*/

// Example 1
// There is no property called colour // Example 1
let car = {
brand: "Ford",
yearsOld: 8,
};

console.log(car["colour"]);

// Example 2
// the object name is just name not firstname// Example 2
function sayHelloToUser(user) {
console.log(`Hello ${user.firstName}`);
}
Expand All @@ -27,7 +27,7 @@ let user = {

sayHelloToUser(user);

// Example 3
// the values should be returned // Example 3
let myPet = {
animal: "Cat",
getName: function() {
Expand Down
9 changes: 6 additions & 3 deletions 1-exercises/D-object-methods/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
*/

let student = {
// write code here
name : "Daniel",
getName: function () {
return "Student name: " + this.name;
// write code here
}

student.getName("Daniel");
}
console.log(student.getName("Daniel"));

/* EXPECTED RESULT

Expand Down
34 changes: 32 additions & 2 deletions 2-mandatory/1-recipes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,35 @@

You should write and log at least 5 recipes
*/

// write code here
// write code here
let recipe = {
frenchToast :{
title: "French Toast",
servings: 6,
ingredients: ["4 large eggs", "1 cup 2% milk", "2 tablespoons sugar", "2 teaspoons vanilla extract", "1/8 teaspoon salt", "12 slices day-old sandwich bread"]
},
homemadeSpaghettiSauce :{
title: "Homemade Spaghetti Sauce",
servings: 12,
ingredients: ["2 pounds ground beef", "1/2 cup water", "Hot cooked spaghetti", "4 cans (6 ounces each) tomato paste", "3/4 pound bulk Italian sausage"]
},
fruitSalad :{
title: "Brunch Fruits Salad",
servings: 10,
ingredients: ["1 can (20 ounces) pineapple chunks", "2 large firm bananas, cut into 1/4-inch chunks", "1 cup of green grapes", "1 can (15 ounces) mandarin oranges", "1 medium red apple"]
},
vanillaFrosting :{
title: "Vanilla Buttercream Frosting",
servings: 5,
ingredients: ["1/2 cup butter, softened", "4-1/2 cups confectioners' sugar", "1-1/2 teaspoons vanilla extract", "5 to 6 tablespoons 2% milk"]
},
garlicBread :{
title: "Garlic Bread",
servings: 8,
ingredients: ["1/2 cup butter, melted", "3 to 4 garlic cloves, minced", "1 loaf (1 pound) French bread, halved lengthwise", "2 tablespoons minced fresh parsley"]
}
}

// write code here
console.log(recipe.frenchToast);
console.log (recipe.frenchToast.ingredients)
2 changes: 1 addition & 1 deletion 2-mandatory/2-currency-code-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ test("creates country currency code lookup", () => {
NG: "NGN",
MX: "MXN",
});
});
});
11 changes: 10 additions & 1 deletion 2-mandatory/3-shopping-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,16 @@ let pantry = {
};

function createShoppingList(recipe) {
// write code here
let ingredientNeeded = recipe.ingredients.filter((ingredient) => {
return (
!pantry.fridgeContents.includes(ingredient) &&
!pantry.cupboardContents.includes(ingredient)
);
});
return {
name: recipe.name,
items: ingredientNeeded,
}; // write code here
}

/* ======= TESTS - DO NOT MODIFY =====
Expand Down
23 changes: 21 additions & 2 deletions 2-mandatory/4-restaurant.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,27 @@ const MENU = {
};

let cashRegister = {
// write code here
}
orderBurger: function (balance) {
if (balance >= MENU.burger) {
let newBalance = MENU.burger - balance;
return newBalance;
} else {
return balance;
}
},

orderFalafel: function (balance){
if (balance >= MENU.falafel) {
let newBalance = MENU.falafel - balance;
return newBalance;
}else {
return balance;
}
}

}
console.log(cashRegister.orderBurger(7.00))
// write code here

/* ======= TESTS - DO NOT MODIFY =====
- To run the tests for this exercise, run `npm test -- --testPathPattern 4-restaurant.js`
Expand Down