-
-
Notifications
You must be signed in to change notification settings - Fork 265
London 9 - Abdulmajid Rammali - JS Core-2 - Week 1 #166
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 |
|---|---|---|
|
|
@@ -16,7 +16,7 @@ let student = { | |
| */ | ||
|
|
||
| // write code here | ||
|
|
||
| student["attendance"] = 90; | ||
| /* | ||
| - Write an "if" statement that changes the value of hasPassed to true | ||
| if the student has attendance that is equal or greater than 90 | ||
|
|
@@ -27,6 +27,10 @@ let student = { | |
|
|
||
| // write code here | ||
|
|
||
| if (student.attendance >= 90 && student.examScore > 60) { | ||
| 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 add else for false value too :) . |
||
| console.log(student); | ||
|
|
||
| /* EXPECTED RESULT | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,4 +22,24 @@ | |
| You should write and log at least 5 recipes | ||
| */ | ||
|
|
||
| // write code here | ||
| // write code here | ||
|
|
||
| let recipe1 = { | ||
| title: "Mole", | ||
| servings: 2, | ||
| ingredients: ["cinnamon", "cumin", "cocoa"] | ||
| } | ||
|
|
||
| console.log(recipe1.title); | ||
| console.log(`Serves: ${recipe1.servings}`); | ||
| console.log("Ingredients:"); | ||
| for (let ingredient of recipe1.ingredients) { | ||
| console.log(ingredient); | ||
| } | ||
|
|
||
|
|
||
|
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. here we wanted you to create 5 receipts and show each key of each receipts in one line , can you think of the solution, if you need help just @ me here, I can send you some tips and the solution :) |
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,12 @@ const COUNTRY_CURRENCY_CODES = [ | |
|
|
||
| function createLookup(countryCurrencyCodes) { | ||
| // write code here | ||
| let lookup = {}; | ||
| for (let [countryCode, currencyCode] of countryCurrencyCodes) { | ||
| lookup[countryCode] = currencyCode; | ||
| } | ||
| return lookup; | ||
|
|
||
|
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 :) |
||
| } | ||
|
|
||
| /* ======= TESTS - DO NOT MODIFY ===== | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,18 @@ let pantry = { | |
|
|
||
| function createShoppingList(recipe) { | ||
| // write code here | ||
| let shoppingList = { | ||
| name: recipe.name, | ||
| items: [] | ||
| }; | ||
|
|
||
| for (let ingredient of recipe.ingredients) { | ||
| if (!pantry.fridgeContents.includes(ingredient) && !pantry.cupboardContents.includes(ingredient)) { | ||
|
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. well done, you can also use concat to merge two arrays and check once if the value is in there or not , so you can merge the |
||
| shoppingList.items.push(ingredient); | ||
| } | ||
| } | ||
|
|
||
| return shoppingList; | ||
| } | ||
|
|
||
| /* ======= TESTS - DO NOT MODIFY ===== | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,19 @@ const MENU = { | |
|
|
||
| let cashRegister = { | ||
| // write code here | ||
| orderBurger(balance) { | ||
| if (balance >= MENU.burger) { | ||
| return balance - MENU.burger; | ||
| } | ||
| return balance; | ||
| }, | ||
|
|
||
| orderFalafel(balance) { | ||
| if (balance >= MENU.falafel) { | ||
| return balance - MENU.falafel; | ||
| } | ||
| return balance; | ||
| } | ||
|
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 use ternary operator 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.
good job, you can also do it with map/forEach function in one line :
basketballTeam.topPlayers.sort().forEach/map(player => console.log(player))