Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sprint-1/destructuring/exercise-1/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const personOne = {

// Update the parameter to this function to make it work.
// Don't change anything else.
function introduceYourself(___________________________) {
function introduceYourself({ name, age, favouriteFood }) {
console.log(
`Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.`
);
Expand Down
14 changes: 14 additions & 0 deletions Sprint-1/destructuring/exercise-2/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,17 @@ let hogwarts = [
occupation: "Teacher",
},
];

// Task 1: Gryffindor members
hogwarts.forEach(({ firstName, lastName, house }) => {
if (house === "Gryffindor") {
console.log(`${firstName} ${lastName}`);
}
});

// Task 2: Teachers with pets
hogwarts.forEach(({ firstName, lastName, occupation, pet }) => {
if (occupation === "Teacher" && pet) {
console.log(`${firstName} ${lastName}`);
}
});
13 changes: 13 additions & 0 deletions Sprint-1/destructuring/exercise-3/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,16 @@ let order = [
{ itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 },
{ itemName: "Hash Brown", quantity: 4, unitPricePence: 40 },
];

let total = 0;

order.forEach(({ itemName, quantity, unitPricePence }) => {
const itemTotal = quantity * unitPricePence;
total += itemTotal;

console.log(
`${itemName} x${quantity} = £${(itemTotal / 100).toFixed(2)}`
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output format does not match requirements

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The output is still not the same.

You can use a diff tool to compare your output and the expected results:

QTY    ITEM             TOTAL
1     Hot cakes        2.32
2     Apple Pie        2.78
1     Egg McMuffin     2.80
1     Sausage McMuffin 3.00
2     Hot Coffee       2.00
4     Hash Brown       1.60

Total: 14.50
QTY     ITEM                TOTAL
1       Hot Cakes           2.32
2       Apple Pie           2.78
1       Egg McMuffin        2.80
1       Sausage McMuffin    3.00
2       Hot Coffee          2.00
4       Hash Brown          1.60

Total: 14.50

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback. I have now adjusted the formatting, spacing, and capitalisation so that the output matches the expected result exactly. I re-ran the file in Node.js and confirmed the output now aligns with the task requirements.

);
});

console.log(`Total: £${(total / 100).toFixed(2)}`);
Loading