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
5 changes: 5 additions & 0 deletions 1-exercises/A-accessing-values/exercise3.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ let basketballTeam = {

// write code here

let topPlayers = basketballTeam.topPlayers;
topPlayers.sort();

for (let player of topPlayers) {
console.log(player);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job, you can also do it with map/forEach function in one line :
basketballTeam.topPlayers.sort().forEach/map(player => console.log(player))

/* EXPECTED RESULT

Dennis Rodman
Expand Down
6 changes: 5 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,11 @@ 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
6 changes: 5 additions & 1 deletion 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 @@ -27,6 +27,10 @@ let student = {

// write code here

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job, you can add else for false value too :) .
you can use ternary operator as well

console.log(student);

/* EXPECTED RESULT
Expand Down
3 changes: 3 additions & 0 deletions 1-exercises/C-undefined-properties/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ let car = {
};

console.log(car["colour"]);
// there is no value for colour.

// Example 2
function sayHelloToUser(user) {
Expand All @@ -26,6 +27,7 @@ let user = {
};

sayHelloToUser(user);
// firstName isn't defined for the console to log it , if we put name instead of firstName then it will print Mira.

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

console.log(myPet.getName());
// The function getName: doesn't have a return to return the string
4 changes: 4 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,10 @@

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

}

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

// write code here
// write code here

let recipe1 = {
title: "Mole",
servings: 2,
ingredients: ["cinnamon", "cumin", "cocoa"]
}

console.log(recipe1.title);
console.log(`Serves: ${recipe1.servings}`);
console.log("Ingredients:");
for (let ingredient of recipe1.ingredients) {
console.log(ingredient);
}


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we wanted you to create 5 receipts and show each key of each receipts in one line , can you think of the solution, if you need help just @ me here, I can send you some tips and the solution :)






6 changes: 6 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,12 @@ const COUNTRY_CURRENCY_CODES = [

function createLookup(countryCurrencyCodes) {
// write code here
let lookup = {};
for (let [countryCode, currencyCode] of countryCurrencyCodes) {
lookup[countryCode] = currencyCode;
}
return lookup;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job :)

}

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

function createShoppingList(recipe) {
// write code here
let shoppingList = {
name: recipe.name,
items: []
};

for (let ingredient of recipe.ingredients) {
if (!pantry.fridgeContents.includes(ingredient) && !pantry.cupboardContents.includes(ingredient)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well done, you can also use concat to merge two arrays and check once if the value is in there or not , so you can merge the pantry.fridgeContents and pantry.cupboardContents in one array and check includes for that array, does this makes sense? let me know if you need more explanation about this :)

shoppingList.items.push(ingredient);
}
}

return shoppingList;
}

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

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

orderFalafel(balance) {
if (balance >= MENU.falafel) {
return balance - MENU.falafel;
}
return balance;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good job, you can also use ternary operator too :)

}

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