Skip to content

Commit 0d0e33e

Browse files
committed
chore: add extensive dependencies for enhanced functionality and testing support
1 parent 82f218f commit 0d0e33e

File tree

5 files changed

+531
-647
lines changed

5 files changed

+531
-647
lines changed

Sprint-1/destructuring/exercise-1/exercise.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const personOne = {
66

77
// Update the parameter to this function to make it work.
88
// Don't change anything else.
9-
function introduceYourself(___________________________) {
9+
function introduceYourself({ name, age, favouriteFood }) {
1010
console.log(
1111
`Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.`
1212
);

Sprint-1/destructuring/exercise-2/exercise.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,22 @@ let hogwarts = [
7070
occupation: "Teacher",
7171
},
7272
];
73+
// Task 1: Gryffindor members
74+
for (let person of hogwarts) {
75+
const { firstName, lastName, house } = person;
76+
77+
if (house === "Gryffindor") {
78+
console.log(`${firstName} ${lastName}`);
79+
}
80+
}
81+
82+
// -----------------------------
83+
// Task 2: Teachers With Pets
84+
// -----------------------------
85+
for (let person of hogwarts) {
86+
const { firstName, lastName, occupation, pet } = person;
87+
88+
if (occupation === "Teacher" && pet) {
89+
console.log(`${firstName} ${lastName}`);
90+
}
91+
}

Sprint-1/destructuring/exercise-3/exercise.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,23 @@ let order = [
66
{ itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 },
77
{ itemName: "Hash Brown", quantity: 4, unitPricePence: 40 },
88
];
9+
10+
console.log("QTY ITEM TOTAL");
11+
12+
let grandTotal = 0;
13+
14+
for (let item of order) {
15+
const { itemName, quantity, unitPricePence } = item;
16+
17+
const total = (quantity * unitPricePence) / 100;
18+
grandTotal += total;
19+
20+
// Format columns using padding
21+
const qtyCol = String(quantity).padEnd(7);
22+
const itemCol = itemName.padEnd(20);
23+
const totalCol = total.toFixed(2);
24+
25+
console.log(`${qtyCol}${itemCol}${totalCol}`);
26+
}
27+
28+
console.log("\nTotal: " + grandTotal.toFixed(2));

0 commit comments

Comments
 (0)