-
-
Notifications
You must be signed in to change notification settings - Fork 265
London 9 -Sana Asaf - JavaScript-Core-2-Coursework-Week1 #181
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 |
|---|---|---|
|
|
@@ -15,7 +15,7 @@ let student = { | |
| - Set the value of attendance to 90 | ||
| */ | ||
|
|
||
| // write code here | ||
| student["attendance"]=90; | ||
|
|
||
| /* | ||
| - Write an "if" statement that changes the value of hasPassed to true | ||
|
|
@@ -24,8 +24,9 @@ let student = { | |
| exam score is above 60. | ||
| - Use bracket notation to change the value of hasPassed | ||
| */ | ||
| if (student["examScore"]>60 && student["attendance"]>=90) | ||
| student["hasPassed"] = true ; | ||
|
|
||
|
Member
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. good job, you can also add else : `else{ }` |
||
| // write code here | ||
|
|
||
| console.log(student); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,55 @@ | |
| cocoa | ||
|
|
||
| You should write and log at least 5 recipes | ||
|
|
||
|
|
||
| */ | ||
|
|
||
| // write code here | ||
| let recipe = { | ||
| title :"Mole", | ||
| servings : 2 , | ||
| ingredients : [ | ||
| "cinnamon" , "cumin" , "cocoa" | ||
| ], | ||
| displayRecipe : function (){ | ||
| console.log(this.title); | ||
| console.log("Serves : "+ this.servings); | ||
| console.log("Ingredients:"); | ||
| for (item of this.ingredients){ | ||
| console.log(item); | ||
| } | ||
| } | ||
| } | ||
| let recipe1 = { | ||
| title :"Biryani", | ||
| servings : 2 , | ||
| ingredients : [ | ||
| "rice" , "spices" , "meat" | ||
| ], | ||
| displayRecipe : function (){ | ||
| console.log(this.title); | ||
| console.log("Serves : "+ this.servings); | ||
| console.log("Ingredients:"); | ||
| for (item of this.ingredients){ | ||
| console.log(item); | ||
| } | ||
| } | ||
| } | ||
| let recipe2 = { | ||
| title :"Anda Paratha", | ||
| servings : 2 , | ||
| ingredients : [ | ||
| "eggs" , "spices" , "atta" , "oil" | ||
| ], | ||
| displayRecipe : function (){ | ||
| console.log(this.title); | ||
| console.log("Serves : "+ this.servings); | ||
| console.log("Ingredients:"); | ||
| for (item of this.ingredients){ | ||
| console.log(item); | ||
| } | ||
| } | ||
| } | ||
| recipe.displayRecipe(); | ||
| recipe1.displayRecipe(); | ||
| recipe2.displayRecipe(); | ||
|
Member
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. great job and a great idea, but the question did not want you to have a method inside of each recipe, it is important to do what the questions ask us to do, you should find a way to go through each recipe and console.log the recipe items. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,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 | ||
|
|
||
| */ | ||
|
|
||
| let pantry = { | ||
|
|
@@ -19,7 +20,14 @@ let pantry = { | |
| }; | ||
|
|
||
| function createShoppingList(recipe) { | ||
| // write code here | ||
| let shoppingList = {}; | ||
| shoppingList.name = recipe.name; | ||
| shoppingList.items = []; | ||
| recipe.ingredients.map(item => { | ||
| if (!pantry.fridgeContents.includes(item) && !pantry.cupboardContents.includes(item)) | ||
| shoppingList.items.push(item); | ||
|
Member
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. great job, you can use concat function from Javascript to combine both arrays and have one array and check the items in that array ==> |
||
| }); | ||
| return shoppingList; | ||
| } | ||
|
|
||
| /* ======= TESTS - DO NOT MODIFY ===== | ||
|
|
@@ -50,4 +58,5 @@ test("createShoppingList works for margherita pizza recipe", () => { | |
| name: "margherita pizza", | ||
| items: ["flour", "yeast", "mozarella"] | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
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.
Great job, we wanted to see the name of each player so you should do this instead:
basketballTeam.topPlayers.sort().map(eachPlayer =>. console.log(eachPlayer))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.
Its concise and so neat ! I will try and refactor mine