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
4 changes: 2 additions & 2 deletions 1-exercises/A-accessing-values/exercise2.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let capitalCities = {
UnitedKingdom: "London",
China: "Beijing",
Peru: "Lima"
};
};

/*
You have an object, capitalCities, that contains key/value pairs of countries and their capital cities.
Expand All @@ -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
1 change: 1 addition & 0 deletions 1-exercises/A-accessing-values/exercise3.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let basketballTeam = {
*/

// write code here
basketballTeam.topPlayers.sort().map(x => console.log(x))


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

// write code here
student['attendance'] = 90

/*
- Write an "if" statement that changes the value of hasPassed to true
Expand All @@ -27,6 +28,10 @@ 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,15 +14,15 @@ let car = {
yearsOld: 8,
};

console.log(car["colour"]);
console.log(car["colour"]); //colour does not exist in the object

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

let user = {
name: "Mira"
name: "Mira" //firstName does not exist in user object
};

sayHelloToUser(user);
Expand All @@ -31,7 +31,7 @@ sayHelloToUser(user);
let myPet = {
animal: "Cat",
getName: function() {
"My pet's name is Fluffy";
"My pet's name is Fluffy"; //function is not returning any value
},
};

Expand Down
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(name) {
console.log("Student name: " + name)
}
}

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

// write code here
// write code here
let vicSponge = {
title: 'vicSponge',
servings: 5,
ingredients: ['sugar', 'eggs', 'flour']
};
console.log(vicSponge.title)
console.log('serves: ' + vicSponge.servings)
vicSponge.ingredients.forEach(x => console.log(x))

let lemonCake = {
title: 'lemonCake',
servings: 5,
ingredients: ['sugar', 'eggs', 'flour']
};
console.log(lemonCake.title)
console.log('serves: ' + lemonCake.servings)
lemonCake.ingredients.forEach(x => console.log(x))

let fruitCake = {
title: 'fruitCake',
servings: 5,
ingredients: ['sugar', 'eggs', 'flour']
};
console.log(fruitCake.title)
console.log('serves: ' + fruitCake.servings)
fruitCake.ingredients.forEach(x => console.log(x))

let carrotCake = {
title: 'cake',
servings: 5,
ingredients: ['sugar', 'eggs', 'flour']
};
console.log(carrotCake.title)
console.log('serves: ' + carrotCake.servings)
carrotCake.ingredients.forEach(x => console.log(x))

let bananaLoaf = {
title: 'bananaLoaf',
servings: 5,
ingredients: ['sugar', 'eggs', 'flour']
};
console.log(bananaLoaf.title)
console.log('serves: ' + bananaLoaf.servings)
bananaLoaf.ingredients.forEach(x => console.log(x))
3 changes: 3 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,9 @@ const COUNTRY_CURRENCY_CODES = [

function createLookup(countryCurrencyCodes) {
// write code here
let currencyCode = {}
countryCurrencyCodes.map(x => currencyCode[x[0]] = x[1])
return currencyCode
}

/* ======= TESTS - DO NOT MODIFY =====
Expand Down
9 changes: 8 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 @@ -20,6 +20,13 @@ let pantry = {

function createShoppingList(recipe) {
// write code here
let allContent = pantry.fridgeContents.concat(pantry.cupboardContents)
let shopItems = recipe.ingredients.filter(x => allContent.indexOf(x) < 0)

return {
name: recipe.name,
items: shopItems
}
}

/* ======= 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 >= 0){
return balance - MENU.burger
}
return balance
},
orderFalafel: function(balance){
if(balance - MENU.falafel >= 0){
return balance - MENU.falafel
}
return balance
}
}

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