Skip to content

Commit 43be954

Browse files
committed
Fix object destructuring output formatting
1 parent 5e2b55a commit 43be954

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

Sprint-1/destructuring/exercise-3/exercise.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ let order = [
99

1010
let total = 0;
1111

12+
console.log("QTY ITEM TOTAL");
13+
1214
order.forEach(({ itemName, quantity, unitPricePence }) => {
1315
const itemTotal = quantity * unitPricePence;
1416
total += itemTotal;
1517

1618
console.log(
17-
`${itemName} x${quantity} = £${(itemTotal / 100).toFixed(2)}`
19+
`${String(quantity).padEnd(6)}${itemName.padEnd(17)}${(itemTotal / 100).toFixed(2)}`
1820
);
1921
});
2022

21-
console.log(`Total: £${(total / 100).toFixed(2)}`);
23+
console.log("");
24+
console.log(`Total: ${(total / 100).toFixed(2)}`);

0 commit comments

Comments
 (0)