London10-Afsha-Hossain-JS2-Week1 - #239
Conversation
| */ | ||
|
|
||
| let favouriteRecipe1 = {}; | ||
|
|
There was a problem hiding this comment.
This code looks correct to me 👍
One small comment - usually if you're defining an object and you already know the properties and values, it can be easier (to both write and read) to include all the information in your object definition. Using your example, this will look like:
let favouriteRecipe1 = {
title: "Mole",
servings: 2,
ingredients: ["cinnamon", "cumin", "cocoa"]
};| favouriteRecipe1.servings = 2; | ||
| favouriteRecipe1.ingredients = ["cinnamon", "cumin", "cocoa"]; | ||
|
|
||
|
|
There was a problem hiding this comment.
Seems like we have a lot of duplicate code here to output a recipe in the format that we want.
Can you use a function to reduce the duplication?
| ]; | ||
|
|
||
| function createLookup(countryCurrencyCodes) { | ||
| return Object.fromEntries(countryCurrencyCodes); |
| @@ -19,6 +19,17 @@ let pantry = { | |||
| }; | |||
|
|
|||
| function createShoppingList(recipe) { | |||
There was a problem hiding this comment.
This implementation looks good to me!
For an extra challenge - can you re-write this using the filter array method?
| orderBurger: function(balance){ | ||
| if (balance >= MENU.burger) { | ||
| balance = balance - MENU.burger; | ||
| } else { |
There was a problem hiding this comment.
Do you think the else clause is needed here? What happens if you remove it?
| The rest of the tests have comments describing what to test and you need to | ||
| write a matching test | ||
| */ | ||
|
|
| @@ -55,6 +55,15 @@ function formatCourseworkResult(trainee) { | |||
| score: 63 | |||
| } | |||
| */ | |||
There was a problem hiding this comment.
These tests look good to me, but you might need to think about the best way to name your tests.
Imagine you make a change to your code - and a test starts to fail. In the test output, you might see the output has trainee score or the output has trainee name, Aman - but this won't give you any useful information about which part of the code might be broken. Can you think of better names for these tests?
|
Good work on this coursework @Afsha10 👍 |
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?