Skip to content

Conversation

@i786m
Copy link

@i786m i786m commented Nov 15, 2025

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 tasks set out in exercises 1-3 in the Sprint 1 destructuring folder

Questions

I found it unclear if exercise 2 needed a string output, or a log as the task was to display the desired names. As such I have logged these to the console, should I have been outputting strings instead?

@i786m i786m added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 15, 2025
@ckirby19 ckirby19 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 Nov 15, 2025
Copy link

@ckirby19 ckirby19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I just added come comments around readability

//task 1
function getGryffindorMembers(arr) {
let gryffindorMembers = [];
arr.forEach(({ firstName, lastName, house }) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an extension: could you show me how you can use filter and map on an array to do this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used filter and map for both functions in this exercise

function printReceipt(order){
let total = 0 , qtyWidthMax = 3, itemWidthMax = 4
const receiptLines = order.map(({itemName, quantity, unitPricePence}) => {
const itemTotalPounds = (quantity*unitPricePence/100);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, we try to keep space around an operator to make the code easier to read. Also, just to make the code easier to read, it is better to use brackets to show the order of operation that you want. For example, is it not clear whether you intend to have:

  • quantity * (unitPricePence/100) OR
  • (quantity * unitPricePence) / 100

In this instance, it does not actually matter, as mathematically they are equivalent. But it is a good habit to create to improve your code readability

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted and amended

];

function printReceipt(order){
let total = 0 , qtyWidthMax = 3, itemWidthMax = 4

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just formatting: We usually don't add a comma after a number like you have with total = 0 ,

Copy link
Author

@i786m i786m Nov 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noted, have declared and assigned variables individually to aid in readability.

@ckirby19 ckirby19 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 Nov 15, 2025
@i786m i786m 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 Nov 16, 2025
@i786m i786m requested a review from ckirby19 November 16, 2025 15:22

//task 1
function getGryffindorMembers(arr) {
const gryffindorMembers = arr.filter(({ house }) => house === "Gryffindor").map(({ firstName, lastName }) => `${firstName} ${lastName}`).join('\n');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, great work. The only thing I would say is that we typically keep each method applied on a new line just to improve readability again. So, to take your work as an example:

image

@ckirby19 ckirby19 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 23, 2025
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants