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["UnitedKingdom"]; // 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 @@ -22,6 +22,9 @@ let basketballTeam = {

// write code here

let topBasketballPlayer = basketballTeam.topPlayers.sort();
topBasketballPlayer.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 @@ -24,6 +24,12 @@ let capitalCities = {

// write code here

capitalCities.UnitedKingdom.population = 8980000;
capitalCities.China.population = 21500000;
capitalCities.Peru={};
capitalCities.Peru.name = "Lima";
capitalCities.Peru.population = 9750000;

console.log(capitalCities);

/* EXPECTED RESULT
Expand Down
11 changes: 11 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 All @@ -27,8 +29,17 @@ 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,7 +14,7 @@ let car = {
yearsOld: 8,
};

console.log(car["colour"]);
console.log(car["colour"]); // We have not define colour yet!

// Example 2
function sayHelloToUser(user) {
Expand All @@ -25,7 +25,7 @@ let user = {
name: "Mira"
};

sayHelloToUser(user);
sayHelloToUser(user); // we didn't define variable as firstName or we used wrongly firstName instead of name.

// Example 3
let myPet = {
Expand All @@ -35,4 +35,4 @@ let myPet = {
},
};

console.log(myPet.getName());
console.log(myPet.getName()); // The function is not returning anything, we can use console.log inside of function or write return before the statement.
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 @@ -7,11 +7,14 @@
- console.logs a message that says: "Student name: " followed by the name given as an argument
*/

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


student.getName("Daniel");

/* EXPECTED RESULT

Expand Down
35 changes: 34 additions & 1 deletion 2-mandatory/1-recipes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,37 @@
You should write and log at least 5 recipes
*/

// write code here
// write code here

let recipes = {
roastBeef :{
title : `Roast beef`,
servings: 6,
ingredients:["peppercorn" ,"dried thyme", " English mustard powder" , " 8oz topside joint of beef","celery seeds", " olive oil"]
},
CherryAlmond :{
title : `Cherry & almond tarts`,
servings: 12,
ingredients:["eggs" ," self-raising flour", "cherry jam" , "softened","ground almond"]
},
RoastLamb :{
title : `Roast lamb`,
servings: 8,
ingredients:["carrots" ,"onion", "small bunch parsley" ,"thyme leaf", "lemon"]
},
Scampi :{
title : `Scampi with tartare sauce`,
servings: 2,
ingredients:["cornflour" ,"sparkling water", "beer" ,"Dublin Bay prawn tails", " olive oil"]
}
}
function printOut(meals) {
console.log( recipes[meals]["title"]);
console.log("Serves: " + recipes[meals]["servings"]);
console.log(" Ingredients:" + recipes[meals]["ingredients"].map(x=> x + " \n "));
}

printOut("roastBeef");
printOut("CherryAlmond");
printOut("RoastLamb");
printOut("Scampi");
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 currencyObject ={};
for (let currency of countryCurrencyCodes) {
currencyObject[currency[0]] = currency[1];
}
return currencyObject;
}

/* ======= TESTS - DO NOT MODIFY =====
Expand Down
17 changes: 16 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,21 @@ let pantry = {

function createShoppingList(recipe) {
// write code here
let shopinglist = {};
shopinglist.name = recipe.name;

let arrayofShopping = [];
for (item of recipe.ingredients) {
if (
pantry.fridgeContents.indexOf(item) !== -1 ||
pantry.cupboardContents.indexOf(item) !== -1
) {
} else {
arrayofShopping.push(item);
}
}
shopinglist.items = arrayofShopping;
return shopinglist;
}

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

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

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