Skip to content

Conversation

@TzeMingHo
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

I have completed the exercises with function destructuring the needed properties

@TzeMingHo TzeMingHo added 📅 Sprint 1 Assigned during Sprint 1 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 29, 2025
@illicitonion illicitonion added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 29, 2025
Copy link
Member

@illicitonion illicitonion left a 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 illicitonion added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Oct 29, 2025
@TzeMingHo TzeMingHo added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 30, 2025
Copy link
Member

@illicitonion illicitonion left a 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}) => {
Copy link
Member

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 :)

Copy link
Author

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], " ")}`
Copy link
Member

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.

Copy link
Author

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?

Copy link

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!)

Copy link
Author

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.

@illicitonion illicitonion added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 31, 2025
@TzeMingHo TzeMingHo added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 31, 2025
@illicitonion illicitonion added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 7, 2025
@illicitonion
Copy link
Member

This looks great, well done!

I'd recommend adding a JSDoc comment to the function which takes ...args to make it easier for other developers to follow. Ideally a developer should be able to understand everything they need to in order to call a function from its signature (name/parameters) and its documentation comments (purpose, restrictions on parameters, return type, etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. 📅 Sprint 1 Assigned during Sprint 1 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants