Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
a73505a
Fix function parameter to enable destructuring in introduceYourself
moses77-boop Nov 19, 2026
947cf46
Fix logic error in getGryffindorNames function to correctly filter Gr…
moses77-boop Nov 19, 2026
5ce61aa
Fix logic error in getGryffindorNames function by removing semicolon
moses77-boop Nov 19, 2026
6348149
Remove unused variable assignment in getGryffindorNames function
moses77-boop Nov 19, 2026
250e5c1
Fix formatting in getGryffindorNames function for consistency
moses77-boop Nov 19, 2026
2e22273
Add getTeachersWithPets function to retrieve teachers with pets
moses77-boop Nov 19, 2026
4bfbbe4
Fix destructuring in getTeachersWithPets function and add console log…
moses77-boop Nov 19, 2026
f3a7bb6
Add totalPence calculation and iterate over order items
moses77-boop Nov 20, 2026
95ed4d6
Add calculate totalPence for order items in the loop
moses77-boop Nov 20, 2026
4ae94fc
Add total calculation for each item in order and format as currency
moses77-boop Nov 20, 2026
37cfc9b
Add console log formatting for order items in total calculation
moses77-boop Nov 20, 2026
0bf83e0
Add total calculation output for order items
moses77-boop Nov 20, 2026
89fbcc8
Add header formatting for order items output
moses77-boop Nov 20, 2026
91bdda3
Fix variable naming in total calculation of order items
moses77-boop Nov 25, 2026
cd27740
Refactor getGryffindorNames function to use destructuring
moses77-boop Nov 25, 2026
84b884c
Refactor getTeachersWithPets function to use destructuring in the for…
moses77-boop Nov 25, 2026
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
26 changes: 26 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,29 @@ let hogwarts = [
occupation: "Teacher",
},
];

function getGryffindorNames(people) {
let gryffindorNames = [];

for (let { firstName, lastName, house } of people) {
if (house === "Gryffindor") {
gryffindorNames.push(firstName + " " + lastName);
}
}
return gryffindorNames;
}

console.log(getGryffindorNames(hogwarts).join("\n"));

function getTeachersWithPets(people) {
let teacherName = [];

for (let { firstName, lastName, pet, occupation } of people) {
if (occupation === "Teacher" && pet !== null) {
teacherName.push(firstName + " " + lastName);
}
}
return teacherName;
}

console.log(getTeachersWithPets(hogwarts).join("\n"));
18 changes: 18 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,21 @@ let order = [
{ itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 },
{ itemName: "Hash Brown", quantity: 4, unitPricePence: 40 },
];

console.log("QTY".padEnd(8) + "ITEM".padEnd(20) + "TOTAL");

let totalPence = 0;

for (const item of order) {
const { itemName, quantity, unitPricePence } = item;

const pence = quantity * unitPricePence;
totalPence += pence;

const total = (pence / 100).toFixed(2);

console.log(String(quantity).padEnd(8) + itemName.padEnd(20) + total);
}

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