Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all 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 array-destructuring/exercise-1/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const personOne = {
favouriteFood: "Spinach",
};

function introduceYourself(___________________________) {
function introduceYourself({ age, favouriteFood }) {
console.log(
`Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.`
);
Expand Down
6 changes: 6 additions & 0 deletions array-destructuring/exercise-2/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,9 @@ let hogwarts = [
occupation: "Teacher",
},
];

const peopleBelongingToGryffindorHouse = () => {
hogwarts.forEach(({firstName, lastName, house}) => {if(house === 'Gryffindor') {console.log(`${firstName} ${lastName}`)}});
}

peopleBelongingToGryffindorHouse();
10 changes: 10 additions & 0 deletions array-destructuring/exercise-3/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,13 @@ let order = [
{ itemName: "Hot Coffee", quantity: 2, unitPrice: 1.0 },
{ itemName: "Hash Brown", quantity: 4, unitPrice: 0.4 },
];

const printOutOrderReceipt = () => {
console.log('QTY', 'ITEM', 'TOTAL');
order.forEach(({itemName, quantity, unitPrice}) => console.log(quantity, itemName, unitPrice*quantity));
const total = order.reduce((acc, {quantity, unitPrice}) => acc + quantity * unitPrice, 0)
console.log(`Total: ${total}`)
}

printOutOrderReceipt();