From d12dca275fec9007e5c074967d90702ab0471741 Mon Sep 17 00:00:00 2001 From: Kirill Kovzel Date: Tue, 16 Jul 2024 15:47:35 +0100 Subject: [PATCH 1/4] Add recommended VS Code extensions --- .vscode/extensions.json | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .vscode/extensions.json diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..25549074 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + "recommendations": [ + "esbenp.prettier-vscode", + "dbaeumer.vscode-eslint", + "streetsidesoftware.code-spell-checker", + "eamodio.gitlens", + "ritwickdey.LiveServer", + "vsliveshare.vsliveshare" + ] +} From 53f8cf16fe702b3be17a9f0f20a2e2277ce41cef Mon Sep 17 00:00:00 2001 From: Syed Arslan Date: Fri, 17 Jan 2025 14:28:57 +0100 Subject: [PATCH 2/4] complete exercise 1 task --- object-destructuring/exercise-1/exercise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/object-destructuring/exercise-1/exercise.js b/object-destructuring/exercise-1/exercise.js index a6eab299..1927a0ac 100644 --- a/object-destructuring/exercise-1/exercise.js +++ b/object-destructuring/exercise-1/exercise.js @@ -4,7 +4,7 @@ const personOne = { favouriteFood: "Spinach", }; -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}.` ); From 4f08942f858929a62b1a465c18a1c7da57ec620b Mon Sep 17 00:00:00 2001 From: Syed Arslan Date: Fri, 17 Jan 2025 14:46:43 +0100 Subject: [PATCH 3/4] complete exercise 2 task --- object-destructuring/exercise-2/exercise.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/object-destructuring/exercise-2/exercise.js b/object-destructuring/exercise-2/exercise.js index e11b75eb..381a9cf0 100644 --- a/object-destructuring/exercise-2/exercise.js +++ b/object-destructuring/exercise-2/exercise.js @@ -70,3 +70,23 @@ let hogwarts = [ occupation: "Teacher", }, ]; + +function display_Gryffindor_house_person(hogwarts){ + hogwarts.forEach(({firstName,lastName,house,pet}) => { + if(house === "Gryffindor"){ + console.log(`${firstName} ${lastName}`); + } + }); +} + +function people_have_pet(hogwarts){ + console.log("people that have pet"); + hogwarts.forEach(({firstName,lastName,pet}) => { + if(pet !== null){ + console.log(`${firstName} ${lastName}`); + } + }); +} + +display_Gryffindor_house_person(hogwarts); +people_have_pet(hogwarts); \ No newline at end of file From 8d7c4b2d33f5375a8bce26b8eb292526b93f1c01 Mon Sep 17 00:00:00 2001 From: Syed Arslan Date: Fri, 17 Jan 2025 15:20:04 +0100 Subject: [PATCH 4/4] complete exercise 3 task --- object-destructuring/exercise-3/exercise.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/object-destructuring/exercise-3/exercise.js b/object-destructuring/exercise-3/exercise.js index 0a01f8f0..805f02c3 100644 --- a/object-destructuring/exercise-3/exercise.js +++ b/object-destructuring/exercise-3/exercise.js @@ -6,3 +6,19 @@ let order = [ { itemName: "Hot Coffee", quantity: 2, unitPrice: 1.0 }, { itemName: "Hash Brown", quantity: 4, unitPrice: 0.4 }, ]; + +function order_receipt(order) { + console.log("Qnt ITEM UNIT PRICE"); + let totalPrice = 0; + + order.forEach(({ itemName, quantity, unitPrice }) => { + const itemTotal = quantity * unitPrice; + totalPrice += itemTotal; + console.log( + `${String(quantity).padEnd(8)}${itemName.padEnd(20)}${unitPrice.toFixed()}` + ); + }); + + console.log(`\nTotal: ${totalPrice.toFixed(2)}`); +} +order_receipt(order); \ No newline at end of file