London | 26-ITP-Jan | Mohsen Zamani | Sprint 1 | Destructuring#378
London | 26-ITP-Jan | Mohsen Zamani | Sprint 1 | Destructuring#378mohsenzamanist wants to merge 5 commits intoCodeYourFuture:mainfrom
Conversation
| // Update the parameter to this function to make it work. | ||
| // Don't change anything else. | ||
| function introduceYourself(___________________________) { | ||
| function introduceYourself({ name, age, favouriteFood }) { |
There was a problem hiding this comment.
This is okay. Whenever you create a function that receives parameters, there is a possibility one of the params is not provided. Try to do some research and see how to prevent your program from crashing when it happens.
| // Don't change anything else. | ||
| function introduceYourself(___________________________) { | ||
| function introduceYourself({ | ||
| name = "NO_NAME_PROVIDED", |
There was a problem hiding this comment.
you've added default values to the function to protect against the function being used without parameters.
thats great!
| } | ||
|
|
||
| introduceYourself(personOne); | ||
| introduceYourself(); |
There was a problem hiding this comment.
according to the assignment, you aren't allowed to change any lines besides the function.
the change you made causes the function with no parameters, which only outputs the default values you added
| ); | ||
| }; | ||
|
|
||
| // GryffindorHouse(hogwarts); |
| occupation === "Teacher" && pet && console.log(`${firstName} ${lastName}`) | ||
| ); | ||
| }; | ||
|
|
There was a problem hiding this comment.
see what the console output is when you run both of these methods GryffindorHouse and teacherHasPet after each other.
You may want to look at formatting the output better so that when these 2 methods are run its easy to see what the answer is for question 1 and question 2 of this exercise
| }, | ||
| ]; | ||
|
|
||
| const GryffindorHouse = (hogwarts) => { |
There was a problem hiding this comment.
please check the style guide regarding method naming so that your code is consistent and easily readable
| let total = 0; | ||
| order.forEach(({ itemName, quantity, unitPricePence }) => { | ||
| console.log( | ||
| `${quantity}${" ".repeat(7)}${itemName}${" ".repeat(20 - itemName.length)}${String(unitPricePence / 100).padEnd(4, 0)}` |
There was a problem hiding this comment.
nice work on the output formatting here
Learners, PR Template
Self checklist
Changelist
Complete Sprint 1 Destructuring.
Questions