From 55460ddb7ae4eddcea27eb83c31b81956e69a20e Mon Sep 17 00:00:00 2001 From: Joemwa Date: Sat, 18 Mar 2023 12:06:18 +0000 Subject: [PATCH 1/3] I wrote something on line 19 --- 1-exercises/A-accessing-values/exercise1.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/1-exercises/A-accessing-values/exercise1.js b/1-exercises/A-accessing-values/exercise1.js index 67416c69..52941c2e 100644 --- a/1-exercises/A-accessing-values/exercise1.js +++ b/1-exercises/A-accessing-values/exercise1.js @@ -8,7 +8,7 @@ let dog = { breed: "Dalmatian", name: "Spot", isHungry: true, - happiness: 6 + happiness: 6, }; /* @@ -16,13 +16,13 @@ let dog = { Log the name and breed of this dog using dot notation. */ -let dogName; // complete the code +let dogName = 88; // complete the code let dogBreed; // complete the code console.log(`${dogName} is a ${dogBreed}`); /* EXPECTED RESULT - +S Spot is a Dalmatian -*/ \ No newline at end of file +*/ From 6ea1315440dce0405437e9ac11ad204966e99e18 Mon Sep 17 00:00:00 2001 From: Joemwa <109852314+Joemwa@users.noreply.github.com> Date: Wed, 22 Mar 2023 14:15:32 +0000 Subject: [PATCH 2/3] Made changes --- 1-exercises/A-accessing-values/exercise1.js | 8 ++++---- 2-mandatory/1-recipes.js | 9 ++++++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/1-exercises/A-accessing-values/exercise1.js b/1-exercises/A-accessing-values/exercise1.js index 67416c69..dcf5a5ce 100644 --- a/1-exercises/A-accessing-values/exercise1.js +++ b/1-exercises/A-accessing-values/exercise1.js @@ -8,7 +8,7 @@ let dog = { breed: "Dalmatian", name: "Spot", isHungry: true, - happiness: 6 + happiness: 6, }; /* @@ -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}`); @@ -25,4 +25,4 @@ console.log(`${dogName} is a ${dogBreed}`); Spot is a Dalmatian -*/ \ No newline at end of file +*/ diff --git a/2-mandatory/1-recipes.js b/2-mandatory/1-recipes.js index 6243fa9c..d88a68c8 100644 --- a/2-mandatory/1-recipes.js +++ b/2-mandatory/1-recipes.js @@ -22,4 +22,11 @@ You should write and log at least 5 recipes */ -// write code here \ No newline at end of file +// write code here +let recipes = { + title: "Zambian Delicious Dish", + servings: 3, + ingredients: ["Chibwabwa", "Impwa", "Imbalala"], +}; + +console.log(recipes.title); From b9090bcf775a71b3fe38969501792a7ebac05f43 Mon Sep 17 00:00:00 2001 From: Joemwa Date: Wed, 22 Mar 2023 22:09:37 +0000 Subject: [PATCH 3/3] Made some changes. Yet to complete the exercises --- 1-exercises/A-accessing-values/exercise1.js | 4 +-- 1-exercises/A-accessing-values/exercise2.js | 6 ++-- 1-exercises/A-accessing-values/exercise3.js | 7 ++-- 1-exercises/B-setting-values/exercise1.js | 10 ++++-- 1-exercises/B-setting-values/exercise2.js | 8 +++-- 1-exercises/D-object-methods/exercise.js | 7 ++-- 2-mandatory/1-recipes.js | 36 ++++++++++++++++++++- 2-mandatory/2-currency-code-lookup.js | 11 ++++++- 8 files changed, 74 insertions(+), 15 deletions(-) diff --git a/1-exercises/A-accessing-values/exercise1.js b/1-exercises/A-accessing-values/exercise1.js index 52941c2e..8a999c29 100644 --- a/1-exercises/A-accessing-values/exercise1.js +++ b/1-exercises/A-accessing-values/exercise1.js @@ -16,8 +16,8 @@ let dog = { Log the name and breed of this dog using dot notation. */ -let dogName = 88; // 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}`); diff --git a/1-exercises/A-accessing-values/exercise2.js b/1-exercises/A-accessing-values/exercise2.js index 5b523ace..6b354f37 100644 --- a/1-exercises/A-accessing-values/exercise2.js +++ b/1-exercises/A-accessing-values/exercise2.js @@ -7,7 +7,7 @@ let capitalCities = { UnitedKingdom: "London", China: "Beijing", - Peru: "Lima" + Peru: "Lima", }; /* @@ -17,7 +17,7 @@ let capitalCities = { */ let myCountry = "UnitedKingdom"; -let myCapitalCity; // complete the code +let myCapitalCity = capitalCities[UnitedKingdom]; // complete the code console.log(myCapitalCity); @@ -25,4 +25,4 @@ console.log(myCapitalCity); London -*/ \ No newline at end of file +*/ diff --git a/1-exercises/A-accessing-values/exercise3.js b/1-exercises/A-accessing-values/exercise3.js index 2e160dd5..40a8c40b 100644 --- a/1-exercises/A-accessing-values/exercise3.js +++ b/1-exercises/A-accessing-values/exercise3.js @@ -21,7 +21,10 @@ let basketballTeam = { */ // write code here - +const topPlayers = basketballTeam.topPlayers.sort(); +topPlayers.forEach((player) => { + console.log(player); +}); /* EXPECTED RESULT @@ -29,4 +32,4 @@ let basketballTeam = { Michael Jordan Scottie Pippen -*/ \ No newline at end of file +*/ diff --git a/1-exercises/B-setting-values/exercise1.js b/1-exercises/B-setting-values/exercise1.js index 7d0b05c5..11ace72e 100644 --- a/1-exercises/B-setting-values/exercise1.js +++ b/1-exercises/B-setting-values/exercise1.js @@ -10,7 +10,7 @@ let capitalCities = { }, China: { name: "Beijing", - } + }, }; /* @@ -23,6 +23,12 @@ let capitalCities = { */ // write code here +capitalCities.UnitedKingdom["population"] = 8980000; +capitalCities.China["population"] = 21500000; + +capitalCities.Peru = {}; +capitalCities.Peru["Capital City"] = "Lima"; +capitalCities.Peru["Population"] = 9750000; console.log(capitalCities); @@ -34,4 +40,4 @@ console.log(capitalCities); Peru: { name: "Lima", population: 9750000 } } -*/ \ No newline at end of file +*/ diff --git a/1-exercises/B-setting-values/exercise2.js b/1-exercises/B-setting-values/exercise2.js index 59fb7c1e..c9f99f00 100644 --- a/1-exercises/B-setting-values/exercise2.js +++ b/1-exercises/B-setting-values/exercise2.js @@ -6,7 +6,7 @@ let student = { name: "Reshma Saujani", examScore: 65, - hasPassed: false + hasPassed: false, }; /* @@ -16,6 +16,7 @@ let student = { */ // write code here +student["attendance"] = 90; /* - Write an "if" statement that changes the value of hasPassed to true @@ -26,6 +27,9 @@ let student = { */ // write code here +if (student["attendance"] >= 90 && student["examScore"] > 60) { + student["hasPassed"] = true; +} console.log(student); @@ -38,4 +42,4 @@ console.log(student); attendance: 90 } -*/ \ No newline at end of file +*/ diff --git a/1-exercises/D-object-methods/exercise.js b/1-exercises/D-object-methods/exercise.js index 0b57f2e1..69bc37d2 100644 --- a/1-exercises/D-object-methods/exercise.js +++ b/1-exercises/D-object-methods/exercise.js @@ -8,8 +8,11 @@ */ let student = { + getName: function (name) { + console.log(`Student name: ${name}`); + }, // write code here -} +}; student.getName("Daniel"); @@ -17,4 +20,4 @@ student.getName("Daniel"); Student name: Daniel -*/ \ No newline at end of file +*/ diff --git a/2-mandatory/1-recipes.js b/2-mandatory/1-recipes.js index 6243fa9c..b640b073 100644 --- a/2-mandatory/1-recipes.js +++ b/2-mandatory/1-recipes.js @@ -22,4 +22,38 @@ You should write and log at least 5 recipes */ -// write code here \ No newline at end of file +// write code here +let ZamManches = { + title: "Chikanda", + servings: 5, + ingredients: ["Groundnuts", "tubers", "Kotapela"], +}; +console.log(ZamManches); + +let ZamChews = { + title: "Chibwabwa", + servings: 7, + ingredients: ["Imbalala", "Green Leaf", "Cream"], +}; +console.log(ZamChews); + +let ZamSheto = { + title: "Chimpapila", + servings: 2, + ingredients: ["Amataba", "Tomato", "Inswa"], +}; +console.log(ZamSheto); + +let ZamSwalo = { + title: "Tunweko", + servings: 6, + ingredients: ["Amenshi", "Umusalu", "Finkubala"], +}; +console.log(ZamSwalo); + +let ZamShare = { + title: "Kampompo", + servings: 8, + ingredients: ["Ifisali", "Ifipushi", "Umungu"], +}; +console.log(ZamShare); diff --git a/2-mandatory/2-currency-code-lookup.js b/2-mandatory/2-currency-code-lookup.js index 5fde14f1..9065b2cf 100644 --- a/2-mandatory/2-currency-code-lookup.js +++ b/2-mandatory/2-currency-code-lookup.js @@ -19,6 +19,15 @@ const COUNTRY_CURRENCY_CODES = [ function createLookup(countryCurrencyCodes) { // write code here + const lookup = {}; + + for (let i = 0; i < countryCurrencyCodes.length; i++) { + const country = countryCurrencyCodes[i][0]; + const currency = countryCurrencyCodes[i][1]; + lookup[country] = currency; + } + + return lookup; } /* ======= TESTS - DO NOT MODIFY ===== @@ -34,4 +43,4 @@ test("creates country currency code lookup", () => { NG: "NGN", MX: "MXN", }); -}); \ No newline at end of file +});