From 0092abadb3024c0d10335af80fde14ce6535adb3 Mon Sep 17 00:00:00 2001 From: BEKIRKSU <113244972+BEKIRKSU@users.noreply.github.com> Date: Mon, 20 Mar 2023 17:01:14 +0000 Subject: [PATCH 1/8] Exercise 1 done --- 1-exercises/A-accessing-values/exercise1.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/1-exercises/A-accessing-values/exercise1.js b/1-exercises/A-accessing-values/exercise1.js index 67416c69..54d69859 100644 --- a/1-exercises/A-accessing-values/exercise1.js +++ b/1-exercises/A-accessing-values/exercise1.js @@ -5,10 +5,10 @@ */ let dog = { - breed: "Dalmatian", - name: "Spot", - isHungry: true, - happiness: 6 + breed: "Dalmatian", //string + name: "Spot", //string + isHungry: true, //boolean + happiness: 6 //number }; /* @@ -16,10 +16,10 @@ let dog = { Log the name and breed of this dog using dot notation. */ -let dogName; // complete the code -let dogBreed; // complete the code +console.log (dog.name) ; +console.log (dog.breed); -console.log(`${dogName} is a ${dogBreed}`); +console.log(`${dog.name} is a ${dogbreed}`); /* EXPECTED RESULT From 4bb7872e80ed27c40fdb97a8b38ab2b0248e6849 Mon Sep 17 00:00:00 2001 From: BEKIRKSU <113244972+BEKIRKSU@users.noreply.github.com> Date: Mon, 20 Mar 2023 17:06:11 +0000 Subject: [PATCH 2/8] Exercise 2 --- 1-exercises/A-accessing-values/exercise2.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-exercises/A-accessing-values/exercise2.js b/1-exercises/A-accessing-values/exercise2.js index 5b523ace..d53f2d81 100644 --- a/1-exercises/A-accessing-values/exercise2.js +++ b/1-exercises/A-accessing-values/exercise2.js @@ -17,7 +17,7 @@ let capitalCities = { */ let myCountry = "UnitedKingdom"; -let myCapitalCity; // complete the code +let myCapitalCity = (capitalCities["UnitedKingdom"]); // complete the code console.log(myCapitalCity); From a5f98f2169f3554e3fd974ababf5deb2b1817d8c Mon Sep 17 00:00:00 2001 From: BEKIRKSU <113244972+BEKIRKSU@users.noreply.github.com> Date: Mon, 20 Mar 2023 17:21:42 +0000 Subject: [PATCH 3/8] Mandatory 1 --- 2-mandatory/1-recipes.js | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/2-mandatory/1-recipes.js b/2-mandatory/1-recipes.js index 6243fa9c..17bc142c 100644 --- a/2-mandatory/1-recipes.js +++ b/2-mandatory/1-recipes.js @@ -21,5 +21,39 @@ You should write and log at least 5 recipes */ +let recipe1 = { + x: "bread", + cups: 2, + isHungry: ["a", "b", "c",], +}; +console.log(recipe1.cups); + +let recipe2 = { + x: "butter", + cups: 1, + isHungry: ["a", "b", "c",], +}; +console.log(recipe2.isHungry[2]); + +let recipe3 = { + x: "milk", + cups: 4, + fruits: ["apple", "banana", "cherry",], +}; +console.log(recipe3.x); + +let recipe4 = { + x: "strawberry", + teaSpoons: 7, + people: ["a", "b", "c",], +}; +console.log(recipe4.teaSpoons); + +let recipe5 = { + x: "eggs", + cups: 0, + when: ["morning", "afternoon", "evening",], +}; +console.log(recipe5.when[0]); // write code here \ No newline at end of file From a6916eaca93761527ac593a8bd4e76f28c23f4fe Mon Sep 17 00:00:00 2001 From: BEKIRKSU <113244972+BEKIRKSU@users.noreply.github.com> Date: Mon, 20 Mar 2023 23:47:12 +0000 Subject: [PATCH 4/8] Mandatory 3 done --- 2-mandatory/3-shopping-list.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/2-mandatory/3-shopping-list.js b/2-mandatory/3-shopping-list.js index d25cb366..2c5e7c30 100644 --- a/2-mandatory/3-shopping-list.js +++ b/2-mandatory/3-shopping-list.js @@ -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 = { @@ -19,7 +19,21 @@ let pantry = { }; function createShoppingList(recipe) { - // write code here + const missingItems = []; + +recipe.ingredients.forEach((ingredient) => { +if ( +!pantry.fridgeContents.includes(ingredient) && +!pantry.cupboardContents.includes(ingredient) +) { +missingItems.push(ingredient); +} +}); + +return { +name: recipe.name, +items: missingItems +}; } /* ======= TESTS - DO NOT MODIFY ===== From 8b8a8d15a4edb4188c8f5ba5d53a66b97a0006c8 Mon Sep 17 00:00:00 2001 From: BEKIRKSU <113244972+BEKIRKSU@users.noreply.github.com> Date: Tue, 21 Mar 2023 00:24:01 +0000 Subject: [PATCH 5/8] Mandatory 4 done --- 2-mandatory/4-restaurant.js | 44 +++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/2-mandatory/4-restaurant.js b/2-mandatory/4-restaurant.js index d7b81eea..a35bd0c9 100644 --- a/2-mandatory/4-restaurant.js +++ b/2-mandatory/4-restaurant.js @@ -20,8 +20,48 @@ const MENU = { }; let cashRegister = { - // write code here -} + balance: 0, + + orderBurger: function(balance) { + const burgerPrice = MENU.burger; + if (balance >= burgerPrice) { + this.balance = balance - burgerPrice; + return this.balance; + } else { + return balance; + } + }, + orderFalafel: function(balance) { + const falafelPrice = MENU.falafel; + if (balance >= falafelPrice) { + this.balance = balance - falafelPrice; + return this.balance; + } else { + return balance; + } + }, + }; + + // currentBalance: 0, + // orderBurger: function(burgerPrice) { + // if (this.currentBalance - burgerPrice >= 0) { + // this.currentBalance -= burgerPrice; + // return this.currentBalance; + // } else { + // return "You don't have enough money in your card. Sorry mate."; + // } + // } + // }; + +// let currentBalance = balance; +// function orderBurger(balance) { +// if (balance - burger => 0) { +// return balance - burger; +// } else { +// return balance; +// } +// } +// } /* ======= TESTS - DO NOT MODIFY ===== - To run the tests for this exercise, run `npm test -- --testPathPattern 4-restaurant.js` From 525da02108ab4de9437de12fce1f7567227d9662 Mon Sep 17 00:00:00 2001 From: BEKIRKSU <113244972+BEKIRKSU@users.noreply.github.com> Date: Tue, 21 Mar 2023 00:24:26 +0000 Subject: [PATCH 6/8] 4 done --- 2-mandatory/4-restaurant.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/2-mandatory/4-restaurant.js b/2-mandatory/4-restaurant.js index a35bd0c9..b91abdd4 100644 --- a/2-mandatory/4-restaurant.js +++ b/2-mandatory/4-restaurant.js @@ -52,16 +52,6 @@ let cashRegister = { // } // } // }; - -// let currentBalance = balance; -// function orderBurger(balance) { -// if (balance - burger => 0) { -// return balance - burger; -// } else { -// return balance; -// } -// } -// } /* ======= TESTS - DO NOT MODIFY ===== - To run the tests for this exercise, run `npm test -- --testPathPattern 4-restaurant.js` From 457672f8b1fb73417b91ec11e773e8edf4c01954 Mon Sep 17 00:00:00 2001 From: BEKIRKSU <113244972+BEKIRKSU@users.noreply.github.com> Date: Tue, 21 Mar 2023 01:11:14 +0000 Subject: [PATCH 7/8] M 2 Not Done --- 2-mandatory/2-currency-code-lookup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-mandatory/2-currency-code-lookup.js b/2-mandatory/2-currency-code-lookup.js index 5fde14f1..c2ed5255 100644 --- a/2-mandatory/2-currency-code-lookup.js +++ b/2-mandatory/2-currency-code-lookup.js @@ -18,7 +18,7 @@ const COUNTRY_CURRENCY_CODES = [ ]; function createLookup(countryCurrencyCodes) { - // write code here +////////// } /* ======= TESTS - DO NOT MODIFY ===== From 0ce3758a700701cf7ea99507fb8bbf24401249a2 Mon Sep 17 00:00:00 2001 From: BEKIRKSU <113244972+BEKIRKSU@users.noreply.github.com> Date: Tue, 21 Mar 2023 01:18:46 +0000 Subject: [PATCH 8/8] M 4 update --- 2-mandatory/4-restaurant.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/2-mandatory/4-restaurant.js b/2-mandatory/4-restaurant.js index b91abdd4..9993799a 100644 --- a/2-mandatory/4-restaurant.js +++ b/2-mandatory/4-restaurant.js @@ -51,7 +51,7 @@ let cashRegister = { // return "You don't have enough money in your card. Sorry mate."; // } // } - // }; + // }; this code didn't work completely but was interesting. /* ======= TESTS - DO NOT MODIFY ===== - To run the tests for this exercise, run `npm test -- --testPathPattern 4-restaurant.js`