-
-
Notifications
You must be signed in to change notification settings - Fork 185
London | 26-ITP-Jan | Mohsen Zamani | Sprint 1 | Destructuring #378
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
f85c143
1a7b800
fdaca2c
e437be4
98a2af4
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,26 @@ let hogwarts = [ | |
| occupation: "Teacher", | ||
| }, | ||
| ]; | ||
|
|
||
| const GryffindorHousePeople = (hogwarts) => { | ||
| hogwarts.forEach( | ||
| ({ firstName, lastName, house }) => | ||
| house === "Gryffindor" && console.log(`${firstName} ${lastName}`) | ||
| ); | ||
| }; | ||
|
|
||
| const teacherHasPet = (hogwarts) => { | ||
| hogwarts.forEach( | ||
| ({ firstName, lastName, pet, occupation }) => | ||
| occupation === "Teacher" && pet && console.log(`${firstName} ${lastName}`) | ||
| ); | ||
| }; | ||
|
|
||
|
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. see what the console output is when you run both of these methods |
||
| console.log("*****************************"); | ||
| console.log("***Gryffindor House People***"); | ||
| console.log("*****************************"); | ||
| GryffindorHouse(hogwarts); | ||
| console.log("\n\n*****************************"); | ||
| console.log("*********teacherHasPet***********"); | ||
| console.log("*****************************"); | ||
| teacherHasPet(hogwarts); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,17 @@ let order = [ | |
| { itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 }, | ||
| { itemName: "Hash Brown", quantity: 4, unitPricePence: 40 }, | ||
| ]; | ||
|
|
||
| const printReceipt = (order) => { | ||
| console.log("QTY ITEM TOTAL"); | ||
| let total = 0; | ||
| order.forEach(({ itemName, quantity, unitPricePence }) => { | ||
| console.log( | ||
| `${quantity}${" ".repeat(7)}${itemName}${" ".repeat(20 - itemName.length)}${String(unitPricePence / 100).padEnd(4, 0)}` | ||
|
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. nice work on the output formatting here |
||
| ); | ||
| total += unitPricePence; | ||
| }); | ||
| console.log(`\nTotal: ${String(total / 100).padEnd(4, 0)}`); | ||
| }; | ||
|
|
||
| printReceipt(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.
you've added default values to the function to protect against the function being used without parameters.
thats great!