We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent efa5ce8 commit 764f28eCopy full SHA for 764f28e
Sprint-1/destructuring/exercise-3/exercise.js
@@ -6,3 +6,19 @@ let order = [
6
{ itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 },
7
{ itemName: "Hash Brown", quantity: 4, unitPricePence: 40 },
8
];
9
+
10
+console.log("QTY ITEM TOTAL");
11
12
+let totalCost = 0;
13
14
+order.forEach(({ itemName, quantity, unitPricePence }) => {
15
+ const itemTotal = (quantity * unitPricePence) / 100; // Convert pence to pounds/dollars
16
+ totalCost += itemTotal;
17
18
+ // Format each line with spacing to match the expected output
19
+ console.log(
20
+ `${quantity} ${itemName.padEnd(18)}${itemTotal.toFixed(2)}`
21
+ );
22
+});
23
24
+console.log(`\nTotal: ${totalCost.toFixed(2)}`);
0 commit comments