Skip to content

London | 26-ITP-January | Eugenie Ahangama | Sprint 1 | Object Destructing#396

Open
Eugenie-A wants to merge 3 commits intoCodeYourFuture:mainfrom
Eugenie-A:feature/destructuring
Open

London | 26-ITP-January | Eugenie Ahangama | Sprint 1 | Object Destructing#396
Eugenie-A wants to merge 3 commits intoCodeYourFuture:mainfrom
Eugenie-A:feature/destructuring

Conversation

@Eugenie-A
Copy link
Copy Markdown

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

  • Completed exercise 1
  • Completed exercise 2
  • Completed exercise 3

Questions

For exercise 3, is there a better way to format the receipt besides what I've done?

@Eugenie-A Eugenie-A added 🏕 Priority Mandatory This work is expected 🐇 Size Small Around an hour 📅 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. Submit:PR Module-Data-Flows The name of the module. Core This is a core task and should be completed by all trainees labels Apr 3, 2026
Comment on lines +10 to +28
// Print the header line, padding each column to a fixed width
console.log("QTY".padEnd(8) + "ITEM".padEnd(20) + "TOTAL");
// Keep track of running total
let total = 0;

// Loop through each item in the order
order.forEach(({ itemName, quantity, unitPricePence }) => {
// Calculate the line total and convert from pence to pounds
let lineTotal = (quantity * unitPricePence) / 100;
// Add this item's total to the running total
total += lineTotal;
// Print this item line, padding each column to match the header width
console.log(
`${quantity}`.padEnd(8) + itemName.padEnd(20) + lineTotal.toFixed(2)
);
});

// Print the overall total, fixed to 2 decimal places
console.log(`\nTotal: ${total.toFixed(2)}`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

FYI: It is good practice to only include comments for the code if it is not clear by reading it.

@Luro91 Luro91 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 Apr 10, 2026
Copy link
Copy Markdown

@Luro91 Luro91 left a comment

Choose a reason for hiding this comment

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

Well done the code works as expected

@Luro91 Luro91 added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Apr 10, 2026
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. Core This is a core task and should be completed by all trainees Module-Data-Flows The name of the module. 🏕 Priority Mandatory This work is expected 🐇 Size Small Around an hour 📅 Sprint 1 Assigned during Sprint 1 of this module Submit:PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants