-
-
Notifications
You must be signed in to change notification settings - Fork 264
London 10 Maksim Lukianenko JavaScript-Core-2-Coursework-Week1 #207
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 |
|---|---|---|
|
|
@@ -19,8 +19,14 @@ const COUNTRY_CURRENCY_CODES = [ | |
|
|
||
| function createLookup(countryCurrencyCodes) { | ||
| // write code here | ||
| const currencyCode = {}; | ||
| for (let item of countryCurrencyCodes) { | ||
| currencyCode[item[0]] = item[1]; | ||
| } | ||
| return currencyCode; | ||
| } | ||
|
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. Comment: Well done! Consider: You could also use .forEach https://www.w3schools.com/jsref/jsref_foreach.asp const lookup = createLookup(COUNTRY_CURRENCY_CODES); |
||
|
|
||
|
|
||
| /* ======= TESTS - DO NOT MODIFY ===== | ||
| - To run the tests for this exercise, run `npm test -- --testPathPattern 2-currency-code-lookup.js` | ||
| - To run all exercises/tests in the mandatory folder, run `npm test` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,16 @@ let pantry = { | |
|
|
||
| function createShoppingList(recipe) { | ||
| // write code here | ||
| let missingIngredients = []; | ||
| recipe.ingredients.forEach((ingredient) => { | ||
| if (!pantry.fridgeContents.includes(ingredient) && !pantry.cupboardContents.includes(ingredient)) { | ||
| missingIngredients.push(ingredient); | ||
| } | ||
| }) | ||
| return { | ||
| name: recipe.name, | ||
| items: missingIngredients, | ||
| }; | ||
| } | ||
|
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. Comment: Well done! |
||
|
|
||
| /* ======= TESTS - DO NOT MODIFY ===== | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,12 @@ const MENU = { | |
|
|
||
| let cashRegister = { | ||
| // write code here | ||
| orderBurger: function (balance) { | ||
| return balance >= MENU.burger? balance - MENU.burger : balance; | ||
| }, | ||
| orderFalafel: function (balance) { | ||
| return balance >= MENU.falafel? balance - MENU.falafel : balance; | ||
| } | ||
| } | ||
|
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. Comment: Well done! |
||
|
|
||
| /* ======= 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.
Comment: well done