-
-
Notifications
You must be signed in to change notification settings - Fork 142
NW | 25-ITP-Sep | TzeMing Ho | Sprint 1 | feature/destructuring #324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
illicitonion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is generally looking really good, but I left a few comments about how to make your code more readable.
illicitonion
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great! Just a few more small thoughts :)
| } | ||
|
|
||
| function teachersWithPets(hogwarts) { | ||
| return hogwarts.reduce((nameList, {firstName, lastName, pet, occupation}) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd similarly recommend a filter and map here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I have updated the function teachersWithPets as well.
| const orderLineSpacing = [8, 20, 5] | ||
| let formattedOrderLine = '' | ||
| for (let index = 0; index < args.length; index++) { | ||
| formattedOrderLine += `${String(args[index]).padEnd(orderLineSpacing[index], " ")}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cute use of args!
One disadvantage of using ...args is it makes it less clear to someone trying to use your function what arguments it actually expects. I'd recommend adding a check at the start of the function which checks the right number of args was passed (and throws if not), and maybe also a documentation comment explaining what's expected and in which order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would an error message when the length of arguments is not equal to 3 be good enough for users?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i think that'd be sufficient :) (don't forget the comment for the function!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a comment for the function.
|
This looks great, well done! I'd recommend adding a JSDoc comment to the function which takes |
Learners, PR Template
Self checklist
Changelist
I have completed the exercises with function destructuring the needed properties