Repository navigation
London | 25-ITP-Sep | Maharit Belai | Sprint 1 | Object-destructuring #603
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?
Changes from all commits
e3872a6
0b11440
f57117e
307eaa6
4b9365e
7e83992
979bf23
58373a5
b585dcb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
MaharitB marked this conversation as resolved.
Resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,19 @@ let order = [ | |
| { itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 }, | ||
| { itemName: "Hash Brown", quantity: 4, unitPricePence: 40 }, | ||
| ]; | ||
|
|
||
| function receipt(orders) { | ||
| let total = 0; | ||
| console.log(`${"QTY"} ${"ITEM"} ${"Total"}`); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| for ({ itemName, quantity, unitPricePence } of orders) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These variables aren't declared with anything. What would happen if this code ran in strict mode or inside an ES module? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're yet to fix this |
||
| total += quantity * unitPricePence; | ||
|
|
||
| console.log( | ||
| `${quantity.toString().padEnd(4)} ${itemName.toString().padEnd(21)}${((quantity * unitPricePence) / 100).toFixed(2)}` | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The header spacing and the row spacing are set in two different ways. If you changed a column width, how many places would you have to update? Can the header and rows share the same widths?
|
||
| ); | ||
| } | ||
|
|
||
| console.log(`\nTotal:${total.toFixed(2)}`); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Run the program and look at the number printed after |
||
| } | ||
| receipt(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.
Compare your output with the expected result in the task. What would the output look like if you ran this code? Does it match line for line?
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 will return it to the original state only did that to differentiate it from the rest of the out out. it was confusing.