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, // boolean
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 = 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 = capitalCities[myCountry]; // complete the code

console.log(myCapitalCity);

Expand Down
3 changes: 3 additions & 0 deletions 1-exercises/A-accessing-values/exercise3.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ let basketballTeam = {
*/

// write code here
basketballTeam.topPlayers.sort().forEach((player) => {
console.log(player);
});


/* EXPECTED RESULT
Expand Down
4 changes: 3 additions & 1 deletion 1-exercises/B-setting-values/exercise1.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ 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
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 @@ -16,7 +16,7 @@ let student = {
*/

// write code here

student["attendance"] = 90
/*
- 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 All @@ -26,7 +26,9 @@ let student = {
*/

// write code here

if (student['attendance'] >= 90 && student['examScore'] > 60) {
student.hasPassed = true;
}
console.log(student);

/* EXPECTED RESULT
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 @@ -14,13 +14,13 @@ let car = {
yearsOld: 8,
};

console.log(car["colour"]);
console.log(car["colour"]); // color is not defined in the properties "{}"

// Example 2
function sayHelloToUser(user) {
console.log(`Hello ${user.firstName}`);
}

// the firstName is not defined //
let user = {
name: "Mira"
};
Expand All @@ -35,4 +35,4 @@ let myPet = {
},
};

console.log(myPet.getName());
console.log(myPet.getName()); // the function missing return statement
3 changes: 3 additions & 0 deletions 1-exercises/D-object-methods/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

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

student.getName("Daniel");
Expand Down
12 changes: 11 additions & 1 deletion 2-mandatory/1-recipes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,14 @@
You should write and log at least 5 recipes
*/

// write code here
// write code here

let recipe = {
title: "Salad-Snowflake",
servings: 4,
ingredients: ["strained yogurt", "pickles", "walnuts", "cloves of garlic", "bunch dill", "Olive oil"],
};
console.log(recipe.title);
console.log(`Serves: ${recipe.servings}`);
console.log("Ingredients:");
recipe.ingredients.forEach((ingredient) => console.log(ingredient));
5 changes: 5 additions & 0 deletions 2-mandatory/2-currency-code-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ const COUNTRY_CURRENCY_CODES = [

function createLookup(countryCurrencyCodes) {
// write code here
let countryCurrency = {};
countryCurrencyCodes.forEach(currency => {
countryCurrency[currency[0]] = currency[1]
});
return countryCurrency
}

/* ======= TESTS - DO NOT MODIFY =====
Expand Down
17 changes: 17 additions & 0 deletions 2-mandatory/3-shopping-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ let pantry = {

function createShoppingList(recipe) {
// write code here
let recipeName = recipe.name;
let recipeIngredients = recipe.ingredients;

let emptyContainer = [];

recipeIngredients.forEach((item) => {
if (
!pantry.fridgeContents.includes(item) &&
!pantry.cupboardContents.includes(item)
) {
emptyContainer.push(item);
}
});
return {
name: recipeName,
items: emptyContainer,
};
}

/* ======= TESTS - DO NOT MODIFY =====
Expand Down
12 changes: 12 additions & 0 deletions 2-mandatory/4-restaurant.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ const MENU = {

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

/* ======= TESTS - DO NOT MODIFY =====
Expand Down