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
4 changes: 2 additions & 2 deletions 1-exercises/A-accessing-values/exercise1.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ let dog = {
Log the name and breed of this dog using dot notation.
*/

let dogName; // complete the code
let dogBreed; // complete the code
let dogName = dog.name; // complete the code
let dogBreed = dog.breed; // 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
5 changes: 4 additions & 1 deletion 1-exercises/A-accessing-values/exercise3.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ let basketballTeam = {
*/

// write code here
let basketballTopPlayers = ["Michael Jordan", "Scottie Pippen", "Dennis Rodman"];


console.log(basketballTopPlayers[2]);
console.log(basketballTopPlayers[0]);
console.log(basketballTopPlayers[1]);
/* EXPECTED RESULT

Dennis Rodman
Expand Down
10 changes: 8 additions & 2 deletions 1-exercises/B-setting-values/exercise1.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ let capitalCities = {
},
China: {
name: "Beijing",
}
},

};

/*
Expand All @@ -23,7 +24,12 @@ let capitalCities = {
*/

// write code here

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

/* EXPECTED RESULT
Expand Down
4 changes: 4 additions & 0 deletions 1-exercises/B-setting-values/exercise2.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ let student = {

// write code here

student['attendance'] = 90;
if (student['attendance'] >= 90 && student['examScore'] > 60) {
student['hasPassed'] = true;
};
/*
- Write an "if" statement that changes the value of hasPassed to true
if the student has attendance that is equal or greater than 90
Expand Down
2 changes: 2 additions & 0 deletions 1-exercises/C-undefined-properties/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

// Example 1
//The property name 'color' is assigned in console.log but it doesn't exist in our object literal
let car = {
brand: "Ford",
yearsOld: 8,
Expand All @@ -17,6 +18,7 @@ let car = {
console.log(car["colour"]);

// Example 2
// The console.log should be outside the function and also the comma should be added after the value Mira of the property name.
function sayHelloToUser(user) {
console.log(`Hello ${user.firstName}`);
}
Expand Down
6 changes: 5 additions & 1 deletion 1-exercises/D-object-methods/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@
*/

let student = {
// write code here
getName: function(name){
console.log(`Student name: ${name}`);
}
// write code here
};

student.getName("Daniel");


/* EXPECTED RESULT

Student name: Daniel
Expand Down
31 changes: 31 additions & 0 deletions 2-mandatory/1-recipes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,36 @@

You should write and log at least 5 recipes
*/
let recipe = {
recipe1:{
Title: "Samp and Beans",
Serves: 4,
Ingredients:["samp", "beans", "water", 'salt', "spice"],
},
recipe2: {
Title: "5 colours",
Serves: 6,
Ingredients: ["rice","potato salad", "chakalaka","beetroot","lamb"],
}

recipe3: {
Title: "cottage pie",
Serves: 3,
Ingredients: ["mince","tomatoes", "creamy and mash"],
}

recipe4: {
Title: "Roasted chicken",
Serves: 3,
Ingredients: ["chicken","butter", "salt and pepper", "sage"],
}

recipe2: {
Title: "5 colours",
Serves: 6,
Ingredients: ["rice","potato salad", "chakalaka","beetroot","lamb"],
}
}
console.log(recipe.recipe1);
console.log(recipe.recipe2);
// write code here
12 changes: 11 additions & 1 deletion 2-mandatory/3-shopping-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

The createShoppingList function should return an object with two properties:
- "name" of the recipe, which is a string,
- "items", which is an arry of the missing ingredients that need to be on the shopping list
- "items", which is an array of the missing ingredients that need to be on the shopping list
*/

let pantry = {
Expand All @@ -19,6 +19,16 @@ let pantry = {
};

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

Expand Down