London Class 10 - Elena Barker - JS2 - Week 1#262
London Class 10 - Elena Barker - JS2 - Week 1#262ElenaBarker wants to merge 9 commits intoCodeYourFuture:mainfrom
Conversation
Exercises A,B,C and D done
exercises fixed
task 5 done
task 4 done
working on task 3
task 3 done
task 6 done
added more recipes
| */ | ||
|
|
||
| // write code here | ||
| let players = basketballTeam.topPlayers.sort(); |
There was a problem hiding this comment.
instead of calling the method just players you could write 'sortedPlayers' to add more of a description to what the method is doing.
|
|
||
| let myCountry = "UnitedKingdom"; | ||
| let myCapitalCity; // complete the code | ||
| let myCapitalCity = capitalCities["UnitedKingdom"]; // complete the code |
There was a problem hiding this comment.
Can you do this another way instead of hardcoding?
| // write code here | ||
| capitalCities.UnitedKingdom.population = 898000; | ||
| capitalCities.China.population = 21500000; | ||
| capitalCities.Peru = {}; |
There was a problem hiding this comment.
here you could add the new country and its properties in one statement
|
|
||
| // write code here | ||
| if (student["attendance"]>= 90 && student["examScore"]) { | ||
| student.hasPassed = true; |
There was a problem hiding this comment.
I'm not sure if line 29 is bracket notation? how else could you write this line?
| // write code here | ||
| getName: function (name){ | ||
| console.log(`Student name: ${name}`) | ||
| } |
There was a problem hiding this comment.
You could have a go using arrow function syntax here instead?
| console.log(`Ingredients:`); | ||
|
|
||
| for (let i = 0; i<lasagne.ingredients; i++){ | ||
| console.log(lasagne.ingredients[i]) |
There was a problem hiding this comment.
here we need '.length' or else the function will not know how many times to loop around. Instead of doing iterations is there another way you are able to loop in javaScript? have a look a the forEach method.
| // write code here | ||
| const objectCodes = {}; | ||
| for (element of countryCurrencyCodes){ | ||
| objectCodes[element[0]] = element[1]; |
There was a problem hiding this comment.
try not to use words like element as it can make it harder for someone else to read through your code you could use country or currency directly. e.g. instead of element const [country, currency]
| const missingFromThePantry = {}; | ||
| missingFromThePantry.name = recipe.name; | ||
| missingFromThePantry.items = []; | ||
| missingFromThePantry.items = recipe.ingredients.filter ((Ingredient) => { |
There was a problem hiding this comment.
instead of declaring an empty object then adding to it we could directly declare the object.
| missingFromThePantry.items = recipe.ingredients.filter ((Ingredient) => { | ||
| if (!pantry.fridgeContents.includes(Ingredient) && !pantry.cupboardContents.includes(Ingredient)){ | ||
| return true; | ||
| } |
There was a problem hiding this comment.
instead of using the if statement we could use an or function instead within the filter function
| let cashRegister = { | ||
| // write code here | ||
| orderBurger: function (balance) { | ||
| let burgerPrice = balance - MENU.burger; |
There was a problem hiding this comment.
Not too important but we could use more descriptive variables so instead of balance could use remainingBalance
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? I found tricky to write a tests
What do you still not understand?
Any other notes?