London | 26-ITP-January | Eugenie Ahangama | Sprint 1 | Object Destructing#396
Open
Eugenie-A wants to merge 3 commits intoCodeYourFuture:mainfrom
Open
London | 26-ITP-January | Eugenie Ahangama | Sprint 1 | Object Destructing#396Eugenie-A wants to merge 3 commits intoCodeYourFuture:mainfrom
Eugenie-A wants to merge 3 commits intoCodeYourFuture:mainfrom
Conversation
Luro91
reviewed
Apr 10, 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)}`); |
There was a problem hiding this comment.
FYI: It is good practice to only include comments for the code if it is not clear by reading it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learners, PR Template
Self checklist
Changelist
Questions
For exercise 3, is there a better way to format the receipt besides what I've done?