-
-
Notifications
You must be signed in to change notification settings - Fork 267
London_10-Saliha_Popal-JavaScript-Core-2-Coursework-Week1 #244
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ let capitalCities = { | |
| */ | ||
|
|
||
| let myCountry = "UnitedKingdom"; | ||
| let myCapitalCity; // complete the code | ||
| let myCapitalCity = "London"; // complete the code | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here you should use the alternate method of accessing object data, which would be |
||
|
|
||
| console.log(myCapitalCity); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,7 @@ let basketballTeam = { | |
| */ | ||
|
|
||
| // write code here | ||
|
|
||
| console.log(basketballTeam.topPlayers) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here you are expected to sort through this list of |
||
|
|
||
| /* EXPECTED RESULT | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,4 +22,72 @@ | |
| You should write and log at least 5 recipes | ||
| */ | ||
|
|
||
| // write code here | ||
| // Recipe 1 | ||
| let recipe1 = { | ||
| title: "Mole", | ||
| servings: 2, | ||
| ingredients: ["cinnamon", "cumin", "cocoa"] | ||
| }; | ||
|
|
||
| console.log(recipe1.title); | ||
| console.log(`Serves: ${recipe1.servings}`); | ||
| console.log("Ingredients:"); | ||
| for (let i = 0; i < recipe1.ingredients.length; i++) { | ||
| console.log(recipe1.ingredients[i]); | ||
| } | ||
|
|
||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .forEch() is also the best mothod. |
||
| // Recipe 2 | ||
| let recipe2 = { | ||
| title: "Bolani", | ||
| servings: 4, | ||
| ingredients: ["Gandana", "Dough", "oil", "salt", "green pepper"] | ||
| }; | ||
|
|
||
| console.log(recipe2.title); | ||
| console.log(`Serves: ${recipe2.servings}`); | ||
| console.log("Ingredients:"); | ||
| for (let i = 0; i < recipe2.ingredients.length; i++) { | ||
| console.log(recipe2.ingredients[i]); | ||
| } | ||
|
|
||
| // Recipe 3 | ||
| let recipe3 = { | ||
| title: "Borani Badinjan", | ||
| servings: 6, | ||
| ingredients: ["Ege plant", "tomato sauce", "oil", "black pepper", "turmeric", "garlic", "yogurt"] | ||
| }; | ||
|
|
||
| console.log(recipe3.title); | ||
| console.log(`Serves: ${recipe3.servings}`); | ||
| console.log("Ingredients:"); | ||
| for (let i = 0; i < recipe3.ingredients.length; i++) { | ||
| console.log(recipe3.ingredients[i]); | ||
| } | ||
|
|
||
| // Recipe 4 | ||
| let recipe4 = { | ||
| title: "Aye khanum", | ||
| servings: 8, | ||
| ingredients: ["beef mans", "carrot", "potatoes", "onion", "garlic", "oil", "tomato paste", "yogurt", "fresh coriander"] | ||
| }; | ||
|
|
||
| console.log(recipe4.title); | ||
| console.log(`Serves: ${recipe4.servings}`); | ||
| console.log("Ingredients:"); | ||
| for (let i = 0; i < recipe4.ingredients.length; i++) { | ||
| console.log(recipe4.ingredients[i]); | ||
| } | ||
|
|
||
| // Recipe 5 | ||
| let recipe5 = { | ||
| title: "Qabili", | ||
| servings: 6, | ||
| ingredients: ["rice", "oil", "onion", "carrots", "raisin", "salt", "lamb meat", "char masala"] | ||
| }; | ||
|
|
||
| console.log(recipe5.title); | ||
| console.log(`Serves: ${recipe5.servings}`); | ||
| console.log("Ingredients:"); | ||
| for (let i = 0; i < recipe5.ingredients.length; i++) { | ||
| console.log(recipe5.ingredients[i]); | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can avoid repeating yourself here by moving these |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,8 +18,13 @@ const COUNTRY_CURRENCY_CODES = [ | |
| ]; | ||
|
|
||
| function createLookup(countryCurrencyCodes) { | ||
| // write code here | ||
| const lookup = {}; | ||
| for(const [countryCode, currencyCode] of countryCurrencyCodes){ | ||
| lookup[countryCode] = currencyCode; | ||
| } | ||
| return lookup | ||
| } | ||
| console.log(createLookup(COUNTRY_CURRENCY_CODES)); | ||
|
|
||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or we can write the code as following: for (let countryCurrencyCode of countryCurrencyCodes) { return currencyCodeLookup; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think your original solution is better, but this other solution is also nice and clear. |
||
| /* ======= TESTS - DO NOT MODIFY ===== | ||
| - To run the tests for this exercise, run `npm test -- --testPathPattern 2-currency-code-lookup.js` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,18 @@ const MENU = { | |
| }; | ||
|
|
||
| let cashRegister = { | ||
| // write code here | ||
| orderBurger: function(balance){ | ||
| if(balance >= MENU.burger){ | ||
| balance -= MENU.burger; | ||
| } | ||
| return balance; | ||
| }, | ||
| orderFalafel: function(balance){ | ||
| if(balance >= MENU.falafel){ | ||
| balance -= MENU.falafel | ||
| } | ||
| return balance; | ||
| } | ||
| } | ||
|
|
||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. const MENU = { let cashRegister = { There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like your original solution better here too |
||
| /* ======= TESTS - DO NOT MODIFY ===== | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for these two you should access the
dogobject by doingdog.nameordog.breed