NW5 Manchester - Doris Siu - JS2 - Week1 #119
NW5 Manchester - Doris Siu - JS2 - Week1 #119Doris-Siu wants to merge 3 commits intoCodeYourFuture:mainfrom
Conversation
|
|
||
| let myCountry = "UnitedKingdom"; | ||
| let myCapitalCity; // complete the code | ||
| let myCapitalCity = capitalCities["UnitedKingdom"]; // complete the code |
There was a problem hiding this comment.
this works, but you have the myCountry variable available to you so you can also use this in the bracket notation :)
| let topPlayersArr = basketballTeam.topPlayers.sort(); | ||
|
|
||
| topPlayersArr.forEach(player => console. log(player)); |
| capitalCities.Peru = {}; | ||
| capitalCities.Peru.name = "Lima"; | ||
| capitalCities.Peru.population = 975000; |
There was a problem hiding this comment.
this works, you can also set the properties of the Peru object all at once, by setting the name & population when you create the object
| */ | ||
|
|
||
| // write code here | ||
| student["attendence"] = 90; |
|
|
||
| console.log(myPet.getName()); | ||
|
|
||
| // Because in the object method, it omits the keyword return for the string. |
There was a problem hiding this comment.
good explanations for why JavaScript is returning undefined
| } | ||
| console.log(Object.entries(fish)); | ||
|
|
||
| function printRecipe(obj) { |
There was a problem hiding this comment.
this is really good and it's clear you have a good understanding of accessing object keys & values. The question asks for each recipe to be in this format when console.log is used:
Mole
Serves: 2
Ingredients:
cinnamon
cumin
cocoa
Can you think of ways you might change your approach so that it follows this format? (for example not having the title key logged & having the ingredients on a new line)
| let result = {}; | ||
| for (let [country, currency] of countryCurrencyCodes) { | ||
| result[country] = currency; | ||
| } | ||
| return result; |
| // write code here | ||
| let result = {}; | ||
| result.name = recipe["name"]; | ||
| let pantryArr = pantry.fridgeContents.concat(pantry.cupboardContents); |
There was a problem hiding this comment.
I really like how you use concat here to combine the fridge & cupboard items first to make it easier to search through
| orderBurger: function (balance) { | ||
| if (balance >= MENU.burger) { | ||
| let newBalance = balance - MENU.burger; | ||
| return newBalance; | ||
| } else { | ||
| return balance; | ||
| } | ||
| }, |
There was a problem hiding this comment.
good job here, this is a very clear solution & your variable names make it easy to understand if you are unfamiliar with the code
| // write code here | ||
|
|
||
| return wordCount; | ||
|
|
There was a problem hiding this comment.
great job making it onto the extra tasks and on having passing tests! A shorthand way of doing wordCount[word] = wordCount[word] + 1; would be wordCount[word] += 1;
Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in
HOW_TO_MARK.mdin the root of this repositoryYour Details
Homework Details
Notes
What did you find easy?
What did you find hard?
What do you still not understand?
Any other notes?