This repository was archived by the owner on Jan 14, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 265
WM4 - Azin Yadegari - JavaScript -Core2-Week1 #92
Open
AzinYad
wants to merge
6
commits into
CodeYourFuture:main
Choose a base branch
from
AzinYad:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d39327e
exercises & mandatory
AzinYad aa005a4
Final version
AzinYad ba69b7b
Merge pull request #1 from AzinYad/AzinYad
AzinYad 4e19892
extra
AzinYad 208240e
extra
AzinYad e0605d0
Merge pull request #2 from AzinYad/AzinYad
AzinYad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,28 @@ | ||
| /* | ||
| This object has 4 properties | ||
| The properties of the object are all primitive types (string, number or boolean) | ||
| What is the type of each property? | ||
| What is the type of each property? string | ||
| */ | ||
|
|
||
| let dog = { | ||
| breed: "Dalmatian", | ||
| name: "Spot", | ||
| isHungry: true, | ||
| happiness: 6 | ||
| happiness: 6, | ||
| }; | ||
|
|
||
| /* | ||
| You can access the values of each property using dot notation. | ||
| 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}`); | ||
|
|
||
| /* EXPECTED RESULT | ||
|
|
||
| Spot is a Dalmatian | ||
|
|
||
| */ | ||
| */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 = { | ||
|
|
@@ -20,6 +20,25 @@ let pantry = { | |
|
|
||
| function createShoppingList(recipe) { | ||
| // write code here | ||
| let shoppingFor = {}; | ||
| let shoppingList = []; | ||
| // shoppingList= pantryItems.filter(item => !recipe["ingredients"].includes(item)) | ||
|
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. Well done solving the task! Why comment out these two lines in preference for the |
||
| // let pantryItems=pantry["fridgeContents"].concat(pantry["cupboardContents"]) | ||
|
|
||
| for (let item of recipe.ingredients) { | ||
| if ( | ||
| !( | ||
| pantry["fridgeContents"].includes(item) || | ||
| pantry["cupboardContents"].includes(item) | ||
| ) | ||
| ) { | ||
| shoppingList.push(item); | ||
| } | ||
| } | ||
|
|
||
| shoppingFor.name = recipe.name; | ||
| shoppingFor.items = shoppingList; | ||
| return shoppingFor; | ||
| } | ||
|
|
||
| /* ======= TESTS - DO NOT MODIFY ===== | ||
|
|
@@ -43,11 +62,18 @@ test("createShoppingList works for pancakes recipe", () => { | |
| test("createShoppingList works for margherita pizza recipe", () => { | ||
| let recipe2 = { | ||
| name: "margherita pizza", | ||
| ingredients: ["flour", "salt", "yeast", "tinned tomatoes", "oregano", "mozarella"], | ||
| ingredients: [ | ||
| "flour", | ||
| "salt", | ||
| "yeast", | ||
| "tinned tomatoes", | ||
| "oregano", | ||
| "mozarella", | ||
| ], | ||
| }; | ||
|
|
||
| expect(createShoppingList(recipe2)).toEqual({ | ||
| name: "margherita pizza", | ||
| items: ["flour", "yeast", "mozarella"] | ||
| items: ["flour", "yeast", "mozarella"], | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,21 @@ const MENU = { | |
|
|
||
| let cashRegister = { | ||
| // write code here | ||
| } | ||
| orderBurger(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. This is great :) Can you think of a way to avoid duplicating the price of the burger and falafel? Can you think of a reason we'd want to avoid duplicating the price all over the code? |
||
| if (balance >= 6.5) { | ||
| return balance - 6.5; | ||
| } else { | ||
| return balance; | ||
| } | ||
| }, | ||
| orderFalafel(balance) { | ||
| if (balance >= 7.25) { | ||
| return balance - 7.25; | ||
| } else { | ||
| return balance; | ||
| } | ||
| }, | ||
| }; | ||
|
|
||
| /* ======= TESTS - DO NOT MODIFY ===== | ||
| - To run the tests for this exercise, run `npm test -- --testPathPattern 4-restaurant.js` | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.