-
-
Notifications
You must be signed in to change notification settings - Fork 238
Manchester | 26-ITP-Jan | Ofonime Edak | Sprint 1 | Feature/Destructuring #407
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
fd42ed0
269406b
3e0c968
7d1585a
be17291
c27521a
d7d6d4a
0e7a1ac
c4015ff
c7ea35b
65015e9
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,29 @@ let hogwarts = [ | |
| occupation: "Teacher", | ||
| }, | ||
| ]; | ||
|
|
||
| //Task 1 | ||
| function gryffindorHouse(WizardAndWitch) { | ||
| for (let mate of WizardAndWitch) { | ||
| const { firstName, lastName, house} = mate; | ||
| if (house === "Gryffindor") { | ||
| const gryffindorMates = `${firstName} ${lastName} lives in ${house} house `; | ||
| console.log(gryffindorMates); | ||
|
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. The output does not match the requirements: |
||
| } | ||
| } | ||
| } | ||
|
|
||
| gryffindorHouse(hogwarts); | ||
|
|
||
| //Task2 | ||
|
|
||
| function teacherWithPet(WizardAndWitch) { | ||
|
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. How can you ensure that you only use teacheres for exercise 2?
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. Task 2 should only show teachers who have a pet. At the moment it is everyone in the list. |
||
| for (let teacher of WizardAndWitch) { | ||
| const { firstName, lastName, pet,occupation} = teacher; | ||
| if (occupation=== "Teacher" && pet!==null) { | ||
| const teacherPet = `${firstName} ${lastName} has a ${pet}`; | ||
| console.log(teacherPet); | ||
| } | ||
| } | ||
| } | ||
| teacherWithPet(hogwarts); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,30 @@ let order = [ | |
| { itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 }, | ||
| { itemName: "Hash Brown", quantity: 4, unitPricePence: 40 }, | ||
| ]; | ||
|
|
||
| function orderReceipt(orderItems) { | ||
| const totalList = []; | ||
| console.log("QTY ITEM TOTAL"); | ||
| for (const item of orderItems) { | ||
| const { itemName, quantity, unitPricePence } = item; | ||
|
|
||
| const total = ((quantity * unitPricePence) / 100).toFixed(2); | ||
| totalList.push(total); | ||
|
|
||
| console.log( | ||
| `${quantity.toString().padEnd(8)} ` + | ||
| `${itemName.padEnd(17)} ` + | ||
| `${total}` | ||
| ); | ||
| } | ||
|
|
||
| const grandTotal = totalList.reduce((accumulator, current) => { | ||
| const totalCost = Number(accumulator) + Number(current); | ||
| return totalCost; | ||
| }, 0); | ||
| const finalBill = grandTotal.toFixed(2); | ||
| console.log(`Total:${finalBill}`); | ||
|
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. The formatting of the console output does not match the requirements |
||
| console.log("-----------------"); | ||
| } | ||
|
|
||
| orderReceipt(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.
I don't see any console output here
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 logs this message to the console: Hello, my name is Popeye. I am 34 years old and my favourite food is Spinach.
When I run this on my terminal: Module-Data-Flows\sprint-1\destructuring\exercise-1> node exercise.js
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.
My comment refers to exercise 2