-
-
Notifications
You must be signed in to change notification settings - Fork 239
London|25-ITP-September|Alexandru Pocovnicu|Sprint 1|Feature/destructuring #338
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
Changes from all commits
dd91695
40c2ff7
b39385b
63d03e8
b39462d
b5b2a8e
7e6fbb9
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 |
|---|---|---|
|
|
@@ -70,3 +70,15 @@ let hogwarts = [ | |
| occupation: "Teacher", | ||
| }, | ||
| ]; | ||
|
|
||
| hogwarts.map(({ firstName, lastName, house }) => { | ||
| if (house === "Gryffindor") { | ||
| console.log(`${firstName} ${lastName}`); | ||
| } | ||
| }); | ||
|
|
||
| hogwarts.map(({ occupation, pet, firstName, lastName }) => { | ||
| if (occupation === "Teacher" && pet !== null) { | ||
|
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 could do it simpler by doing You don't need to change anything, this is just an improvement you can keep in mind. |
||
| console.log(`${firstName} ${lastName}`); | ||
| } | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,29 @@ let order = [ | |
| { itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 }, | ||
| { itemName: "Hash Brown", quantity: 4, unitPricePence: 40 }, | ||
| ]; | ||
|
|
||
| order.forEach(({ itemName, quantity, unitPricePence }) => { | ||
| let totalPence = quantity * unitPricePence; | ||
| let pence = totalPence % 100; | ||
| let paddedPence = String(pence).padStart(2, "0"); | ||
| let pounds = Math.floor(totalPence / 100); | ||
| let priceEachItem = `${pounds}.${paddedPence}`; | ||
|
Comment on lines
+11
to
+15
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. Why use |
||
|
|
||
| console.log( | ||
| `${String(quantity).padEnd(7, " ")}${itemName.padEnd( | ||
| 20, | ||
| " " | ||
| )}${priceEachItem}` | ||
| ); | ||
| }); | ||
| let sumAllPence = 0; | ||
| order.forEach(({ quantity, unitPricePence }) => { | ||
|
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. Suggestion: you could write this with reduce and it would be much cleaner, this is a perfect use case for reduce. |
||
| sumAllPence += quantity * unitPricePence; | ||
| }); | ||
| let totalBillPence = sumAllPence % 100; | ||
| let paddedTotalBillPence = String(totalBillPence).padStart(2, "0"); | ||
| let totalBillPounds = Math.floor(sumAllPence / 100); | ||
| let totalBill = ` | ||
| Total: ${totalBillPounds}.${totalBillPence}`; | ||
|
|
||
| console.log(totalBill); | ||
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.
It's correct but I think you Prettier is not working properly, the formatting is a bit off.