London | 25-ITP-May | Houssam Lahlah | Sprint 1 | Feature/destructuring#305
London | 25-ITP-May | Houssam Lahlah | Sprint 1 | Feature/destructuring#305HoussamLh wants to merge 5 commits intoCodeYourFuture:mainfrom
Conversation
- Use object destructuring in introduceYourself parameter
…h properties `firstName`, `lastName`, `house`, `pet`, and `occupation` and display the names of the people who belong to the Gryffindor house.
… access itemName, quantity, and unitPricePence.
LonMcGregor
left a comment
There was a problem hiding this comment.
Good work on this task - I think you could improve your solution in task 2. Thanks for your questions:
- Is my use of object destructuring in the functions clear and efficient, or could it be simplified?
Yes, it's perfect
- Are my variable names descriptive enough for readability and understanding?
You've used good variable names
-
Did I follow best practices in calculating totals and formatting the order output in Exercise 3?
Yes, you've used appropriate higher level functions like forEach and reduce. Just be careful of the indentation which is a bit off on lines 40-42 -
Are there any edge cases I might have missed for the functions I wrote?
See my comment in exercise 2
|
|
||
| function displayGryffindors({ firstName, lastName, house, pet, occupation }) { | ||
| if (house !== "Gryffindor") return; | ||
| console.log(`Hello, my name is ${firstName} ${lastName}. I am a ${occupation} at Hogwarts and I belong to the ${house} house. My pet is a ${pet ? pet : 'none'}.`); |
There was a problem hiding this comment.
It is good you have considered that they may not have a pet. However, the output is not very grammatically correct. Can you think of any way to improve that?
(You have some good example output in the readme - see if you can get that working)
There was a problem hiding this comment.
Thank you for the feedback 🙏 You’re right — the sentence didn’t sound natural when there was no pet. I’ve updated the code so that it only mentions the pet if one exists. Now the output matches the example style.
Improve Gryffindor display function for better grammar - Updated pet handling so that the sentence is grammatically correct. - Now only mentions a pet if one exists. - Matches the example style.
|
Good solution to making the pet sentence optional. You are now done with this sprint |
Self checklist
## Changelist
- Exercise 1:
- Exercise 2:
- Exercise 3:
## Questions