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 = capitalCities["UnitedKingdom"]; // complete the code

console.log(myCapitalCity);

Expand Down
4 changes: 4 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,10 @@ let basketballTeam = {
*/

// write code here
let sortedPlayers = basketballTeam.topPlayers.sort()
console.log(sortedPlayers[0])
console.log(sortedPlayers[1])
console.log(sortedPlayers[2])


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

// write code here

capitalCities.UnitedKingdom.population = 8980000
capitalCities.China.population = 21500000
capitalCities.Peru = {name: "Lima", population:975000}

console.log(capitalCities);

/* EXPECTED RESULT
Expand Down
2 changes: 2 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,8 @@ 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 Down
5 changes: 5 additions & 0 deletions 1-exercises/C-undefined-properties/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ let car = {

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

// this is undefined because there is no key for colour

// Example 2
function sayHelloToUser(user) {
console.log(`Hello ${user.firstName}`);
Expand All @@ -27,6 +29,8 @@ let user = {

sayHelloToUser(user);

// this is undefined because there is no key for firstName just name

// Example 3
let myPet = {
animal: "Cat",
Expand All @@ -36,3 +40,4 @@ let myPet = {
};

console.log(myPet.getName());
//There is no name set in the myPet object
4 changes: 3 additions & 1 deletion 1-exercises/D-object-methods/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
*/

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

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

// write code here
// write code here

let recipe = {
Pancakes:{
title: "Pancakes",
serves: 4,
Ingredients: ["Eggs", "Flour", "Milk", "Butter"]
},
LemonCake:{
title: "Lemon Cake",
serves: 8,
Ingredients: ["Eggs", "Flour", "Butter", "Sugar", "Lemons"]
},
Oats:{
title: "Overnight Oats",
serves: 4,
Ingredients: ["Oats", "Apple", "Raisins", "Honey", "Yoghurt", "Milk"]
},
Fritatta:{
title: "Fritatta",
serves: 6,
Ingredients: ["Eggs", "Chicken", "Chorizo", "Vegetables"]
},
Soup:{
title: "Soup",
serves: 8,
Ingredients: ["Onions", "Vegetables", "Chicken", "Stock"]

}


};

console.log(recipe.Pancakes.title)
console.log(`Serves: ${recipe.Pancakes.serves}`)
console.log(`Ingredients:`)
console.log(recipe.Pancakes.Ingredients[0])
console.log(recipe.Pancakes.Ingredients[1])
console.log(recipe.Pancakes.Ingredients[2])
console.log(recipe.Pancakes.Ingredients[3]);

console.log(recipe.LemonCake.title)
console.log(`Serves: ${recipe.LemonCake.serves}`)
console.log(`Ingredients:`)
console.log(recipe.LemonCake.Ingredients[0])
console.log(recipe.LemonCake.Ingredients[1])
console.log(recipe.LemonCake.Ingredients[2])
console.log(recipe.LemonCake.Ingredients[3])
console.log(recipe.LemonCake.Ingredients[4]);


console.log(recipe.Oats.title)
console.log(`Serves: ${recipe.Oats.serves}`)
console.log(`Ingredients:`)
console.log(recipe.Oats.Ingredients[0])
console.log(recipe.Oats.Ingredients[1])
console.log(recipe.Oats.Ingredients[2])
console.log(recipe.Oats.Ingredients[3])
console.log(recipe.Oats.Ingredients[4])
console.log(recipe.Oats.Ingredients[5]);

console.log(recipe.Fritatta.title)
console.log(`Serves: ${recipe.Fritatta.serves}`)
console.log(`Ingredients:`)
console.log(recipe.Fritatta.Ingredients[0])
console.log(recipe.Fritatta.Ingredients[1])
console.log(recipe.Fritatta.Ingredients[2])
console.log(recipe.Fritatta.Ingredients[3]);

console.log(recipe.Soup.title)
console.log(`Serves: ${recipe.Soup.serves}`)
console.log(`Ingredients:`)
console.log(recipe.Soup.Ingredients[0])
console.log(recipe.Soup.Ingredients[1])
console.log(recipe.Soup.Ingredients[2])
console.log(recipe.Soup.Ingredients[3]);
8 changes: 6 additions & 2 deletions 2-mandatory/2-currency-code-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ const COUNTRY_CURRENCY_CODES = [
["MX", "MXN"],
];

function createLookup(countryCurrencyCodes) {
// write code here
function createLookup(countryCurrencyCodes){
let object ={}
for(let element of countryCurrencyCodes){
object[element[0]] = element[1];
}
return object
}

/* ======= TESTS - DO NOT MODIFY =====
Expand Down
7 changes: 6 additions & 1 deletion 2-mandatory/3-shopping-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ let pantry = {
};

function createShoppingList(recipe) {
// write code here
let needToBuy = {}
needToBuy.name = recipe.name
needToBuy.items = recipe.ingredients.filter((element) => {
return(!(pantry.fridgeContents.includes(element))&&!(pantry.cupboardContents.includes(element)))
})
return needToBuy
}

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

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

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