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;
let dogBreed = dog.breed;
Comment thread
khmdagal marked this conversation as resolved.

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]
Comment thread
khmdagal marked this conversation as resolved.

console.log(myCapitalCity);

Expand Down
6 changes: 5 additions & 1 deletion 1-exercises/A-accessing-values/exercise3.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ let basketballTeam = {
*/

// write code here

function basketballPlayers(players) {
const sortedPlayers = players.sort();
Comment thread
khmdagal marked this conversation as resolved.
sortedPlayers.map(element => console.log(element))
}
basketballPlayers(basketballTeam.topPlayers);

/* 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.China.population = 9750000;
Comment thread
khmdagal marked this conversation as resolved.

capitalCities.Peru = { name: "Lima", population: 9750000 }

// capitalCities.peru.population = 9750000;

console.log(capitalCities);

/* EXPECTED RESULT
Expand Down
4 changes: 4 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 @@ -26,6 +27,9 @@ let student = {
*/

// write code here
if (student.attendance >= 90) {
student['hasPassed'] = true
}

Comment thread
khmdagal marked this conversation as resolved.
console.log(student);

Expand Down
12 changes: 12 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"]);

// Answer of exampl1 - the reason undefined output is beacuse the value assign to the colour property.

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

sayHelloToUser(user);
// Answer for example 2 - the function fo sayHelloToUser is accessing wrong property name. fistName is not an existing property in user object.


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

console.log(myPet.getName());
// Answer for example 3
/*
The reason for undefined output in example 3. The getName method is not returning any anything
Two possible ways to output the sting is :
1) to use the return key word.
2) console log the whole statement.
Comment thread
khmdagal marked this conversation as resolved.

*/
7 changes: 6 additions & 1 deletion 1-exercises/D-object-methods/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@

let student = {
// write code here
getName: function(name) {
return name;
}
}

student.getName("Daniel");


console.log(`Student name: ${student.getName("Daniel")}`);
Comment thread
khmdagal marked this conversation as resolved.

/* EXPECTED RESULT

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

// write code here
// write code here

const myCoffeeLatte = {
coffeeTpe: 'Ethiopian',
isOrganic: true,
isRoast: true,
roastLevel: "medium",
shots: 1.5,
ingredients: ['Milk', 'Caremel', 'No Sugar'],
MakeCoffee: function () {
let haveCoffe;
if (this.coffeeTpe === 'Ethiopian' && this.isOrganic === true && this.isRoast === true && this.roastLevel === 'medium') {
console.log('Injoy your ☕ Caramel Latte 😀')
} else {
console.log("Not my COFFEE😉");
}
}
}
console.log(myCoffeeLatte) // this is loging the whole obeject and it's properties.

myCoffeeLatte.ingredients.filter(elements => console.log(elements)) // this is to show the ingredients one in each line.

myCoffeeLatte.MakeCoffee(); // calling makeCoffee method and see how it works.

myCoffeeLatte.isOrganic = false; //this is to check if the conditon is working

myCoffeeLatte.MakeCoffee(); // result after one of the conditions is assign to a false value.
Comment thread
khmdagal marked this conversation as resolved.
5 changes: 4 additions & 1 deletion 2-mandatory/2-currency-code-lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ const COUNTRY_CURRENCY_CODES = [

function createLookup(countryCurrencyCodes) {
// write code here
const currencies = Object.fromEntries(countryCurrencyCodes)
return currencies;
}
console.log(createLookup(COUNTRY_CURRENCY_CODES))

/* ======= TESTS - DO NOT MODIFY =====
Comment thread
khmdagal marked this conversation as resolved.
- To run the tests for this exercise, run `npm test -- --testPathPattern 2-currency-code-lookup.js`
Expand All @@ -34,4 +37,4 @@ test("creates country currency code lookup", () => {
NG: "NGN",
MX: "MXN",
});
});
});
24 changes: 23 additions & 1 deletion 2-mandatory/4-restaurant.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,34 @@ const MENU = {

let cashRegister = {
// write code here
}
orderBurger: function (balance) {
if (balance > MENU.burger || balance - MENU.burger === 0) {
Comment thread
khmdagal marked this conversation as resolved.
return balance - MENU.burger;
} else {
return balance;
}


},

orderFalafel: function (balance) {
if (balance > MENU.falafel || balance - MENU.falafel === 0) {
return balance - MENU.falafel;
} else {
return balance;
}
},
};



/* ======= TESTS - DO NOT MODIFY =====
- To run the tests for this exercise, run `npm test -- --testPathPattern 4-restaurant.js`
- 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!)
else {
return MENU.burger;
}
*/

test("orderBurger subtracts 6.5 from balance", () => {
Expand Down
2 changes: 1 addition & 1 deletion 3-extra/1-count-words.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Example
If the function is given the input:

"you and me and you";
"you and me and you";//

the object returned would be:

Expand Down