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
14 changes: 7 additions & 7 deletions 1-exercises/A-accessing-values/exercise1.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
*/

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 dog.name; // complete the code
// let dog.breed; // complete the code

console.log(`${dogName} is a ${dogBreed}`);
console.log(`${dog.name} is a ${dog.breed}`);

/* EXPECTED RESULT

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
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
console.log(`${basketballTeam["topPlayers"].sort()}`)


/* EXPECTED RESULT
Expand Down
7 changes: 6 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,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
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,8 @@ let student = {
*/

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


/*
- Write an "if" statement that changes the value of hasPassed to true
Expand All @@ -26,6 +28,9 @@ let student = {
*/

// write code here
if (student["attendance"] >= 90 && student["examScore"] > 60){
student["hasPassed"] = true;
}

console.log(student);

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"]);// colour property is not declare for the car object

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

sayHelloToUser(user);
sayHelloToUser(user);// the firstName property does not declared, trying to access property whic is not decalared will return undifined

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

console.log(myPet.getName());
console.log(myPet.getName());// the function getName does not have return
5 changes: 4 additions & 1 deletion 1-exercises/D-object-methods/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

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

student.getName("Daniel");

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

// write code here
// write code here
molerecipe ={
title : "Mole",
servings : 2,
ingredients : ["cinnamon", "cumin", "cocoa"]
}
cheprecipe = {
title: "Chep",
servings: 4,
ingredients: ["Fish", "Oil", "Onion", "Magui", "Galic", "Rice"]
}
gingerrecipe = {
title: "Gingerbeer",
servings: 3,
ingredients: ["Ginger", "Sugar", "Wanter", "Arom"]

}
console.log(molerecipe.title)
console.log(`Serves:${molerecipe.servings}`)
console.log("Ingredients:")
for (item of molerecipe.ingredients){
console.log(item);
}
console.log("--------------------")
console.log(gingerrecipe.title)
console.log(`Serves:${gingerrecipe.servings}`)
console.log("Ingredients:")
for (item of gingerrecipe.ingredients){
console.log(item);
}
console.log("--------------------")
console.log(cheprecipe.title)
console.log(`Serves:${cheprecipe.servings}`)
console.log("Ingredients:")
for (item of cheprecipe.ingredients){
console.log(item);
}
14 changes: 14 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,20 @@ const COUNTRY_CURRENCY_CODES = [

function createLookup(countryCurrencyCodes) {
// write code here
let newObject = {};
for (element of countryCurrencyCodes ){
let country = element[0];
let currency = element[1];
newObject[country] = currency;
// newObject.element[0][0] = element[0][1];
}

// countryCurrencyCodes.map(item=> {forEach(element => {
// console.log(element+":"+element[1])
// });}

// )
return newObject;
}

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

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

/* ======= TESTS - DO NOT MODIFY =====
Expand Down
18 changes: 17 additions & 1 deletion 2-mandatory/4-restaurant.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,26 @@ const MENU = {

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

/* ======= TESTS - DO NOT MODIFY =====
- To run the tests for this exercise, run `npm test -- --testPathPattern 4-restaurant.js`
- To run the tests for this exercise, run `cl`
- To run all exercises/tests in the mandatory folder, run `npm test`
- (Reminder: You must have run `npm install` one time before this will work!)
*/
Expand Down