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
ede02ad
a234fea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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".padEnd(7), "ITEM".padEnd(21), "TOTAL"); | ||
|
|
||
| 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 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. Every variable needs to be declared with |
||
| total += quantity * unitPricePence; | ||
|
|
||
| console.log( | ||
| `${quantity.toString().padEnd(7)} ${itemName.padEnd(22)}${((quantity * unitPricePence) / 100).toFixed(2)}` | ||
| ); | ||
| } | ||
|
|
||
| console.log(`\nTotal: ${(total / 100).toFixed(2)}`); | ||
| } | ||
| receipt(order); | ||
Uh oh!
There was an error while loading. Please reload this page.