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
3 changes: 2 additions & 1 deletion 1-exercises/A-accessing-values/exercise2.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ let capitalCities = {
*/

let myCountry = "UnitedKingdom";
let myCapitalCity; // complete the code
// let myCapitalCity = capitalCities[myCountry] ; // complete the code
let myCapitalCity = capitalCitiesUnitedKingdom ; // complete the code

console.log(myCapitalCity);

Expand Down
8 changes: 7 additions & 1 deletion 1-exercises/A-accessing-values/exercise3.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ let basketballTeam = {
- console.logs the name of each player on a new line
*/

// write code here
const topPlayer = basketballTeam.topPlayers;

// console.log(topPlayer) => for test

const thebest = () => topPlayer.sort();

console.log(thebest())


/* 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,11 @@ let student = {
*/

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

if (student['examScore'] >= 60) {
student['hasPassed'] = true;
}

/*
- Write an "if" statement that changes the value of hasPassed to true
Expand Down
8 changes: 4 additions & 4 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"]); // there is no propetey called 'colour' in in the object

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

sayHelloToUser(user);
sayHelloToUser(user); // there is no propetey called 'firstName' in in the object

// Example 3
let myPet = {
animal: "Cat",
getName: function() {
"My pet's name is Fluffy";
"My pet's name is Fluffy";
},
};

console.log(myPet.getName());
console.log(myPet.getName()); // there is no propetey called firstName in in the objectThe function has no 'return'
11 changes: 9 additions & 2 deletions 1-exercises/D-object-methods/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@

let student = {
// write code here
}

student.getName("Daniel");
getName: function (name) {
console.log(`Student name: ${name}`);
},
};

student.getName("Daniel")




/* EXPECTED RESULT

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

// write code here
// write code here

let one = {
title : 'EggOmlet',
serving : 2 ,
ingrediants : ['4 eggs', 'oil' , 'tomato' , 'onion', 'salt' ],

}
let tow = {
title : 'burger',
serving : 2 ,
ingrediants : ['meat', 'oil' , 'tomato' , 'onion', 'salt' ],

}
let three = {
title : 'chicken',
serving : 2 ,
ingrediants : ['chiken', 'oil' , 'tomato' , 'onion', 'salt' ],

}
let four = {
title : 'fish',
serving : 2 ,
ingrediants : ['fish', 'oil' , 'tomato' , 'onion', 'salt' ],

}
let five = {
title : 'vegan',
serving : 2 ,
ingrediants : ['mix vegs', 'oil' , 'tomato' , 'onion', 'salt' ],

}

console.log(one.title);
console.log(`severs : ${one.serving}`);
console.log(`Ingrediants :
${one.ingrediants[0]}
${one.ingrediants[1]}
${one.ingrediants[2]}
${one.ingrediants[3]}
${one.ingrediants[4]} `);
console.log(tow.title);




console.log(`severs : ${tow.serving}`);
console.log(`Ingrediants :
${tow.ingrediants[0]}
${tow.ingrediants[1]}
${tow.ingrediants[2]}
${tow.ingrediants[3]}
${tow.ingrediants[4]} `);


console.log(three.title);
console.log(`severs : ${three.serving}`);
console.log(`Ingrediants :
${three.ingrediants[0]}
${three.ingrediants[1]}
${three.ingrediants[2]}
${three.ingrediants[3]}
${three.ingrediants[4]} `);



console.log(four.title);
console.log(`severs : ${four.serving}`);
console.log(`Ingrediants :
${four.ingrediants[0]}
${four.ingrediants[1]}
${four.ingrediants[2]}
${four.ingrediants[3]}
${four.ingrediants[4]} `);



console.log(five.title);
console.log(`severs : ${five.serving}`);
console.log(`Ingrediants :
${five.ingrediants[0]}
${five.ingrediants[1]}
${five.ingrediants[2]}
${five.ingrediants[3]}
${five.ingrediants[4]} `);


// console.log(tow);
// console.log(three);
// console.log(four);
// console.log(five);
20 changes: 19 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,25 @@ const COUNTRY_CURRENCY_CODES = [

function createLookup(countryCurrencyCodes) {
// write code here
}
let newObj = {}
for (let x of countryCurrencyCodes ) {
newObj[x[0]] = x[1];

}
return newObj;
}













/* ======= TESTS - DO NOT MODIFY =====
- To run the tests for this exercise, run `npm test -- --testPathPattern 2-currency-code-lookup.js`
Expand Down
15 changes: 15 additions & 0 deletions 2-mandatory/3-shopping-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,23 @@ let pantry = {

function createShoppingList(recipe) {
// write code here

let final = new Object();
let result = [];
for (ingredient of recipe.ingredients) {
if (
!pantry.fridgeContents.includes(ingredient) &&
!pantry.cupboardContents.includes(ingredient)
) {
result.push(ingredient);
}
}
final["name"] = recipe.name;
final["items"] = result;
return final;
}


/* ======= TESTS - DO NOT MODIFY =====
- To run the tests for this exercise, run `npm test -- --testPathPattern 3-shopping-list.js`
- To run all exercises/tests in the mandatory folder, run `npm test`
Expand Down
17 changes: 15 additions & 2 deletions 2-mandatory/4-restaurant.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,21 @@ const MENU = {
};

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



/* ======= TESTS - DO NOT MODIFY =====
- To run the tests for this exercise, run `npm test -- --testPathPattern 4-restaurant.js`
Expand Down