diff --git a/array-destructuring/exercise-1/exercise.js b/array-destructuring/exercise-1/exercise.js index a6eab299..e62de539 100644 --- a/array-destructuring/exercise-1/exercise.js +++ b/array-destructuring/exercise-1/exercise.js @@ -4,10 +4,12 @@ const personOne = { favouriteFood: "Spinach", }; -function introduceYourself(___________________________) { +let { name, age, favouriteFood } = personOne; + +function introduceYourself(personOne) { console.log( `Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.` ); } -introduceYourself(personOne); +introduceYourself(); diff --git a/array-destructuring/exercise-2/exercise.js b/array-destructuring/exercise-2/exercise.js index e11b75eb..e4ea595b 100644 --- a/array-destructuring/exercise-2/exercise.js +++ b/array-destructuring/exercise-2/exercise.js @@ -70,3 +70,16 @@ let hogwarts = [ occupation: "Teacher", }, ]; + + +hogwarts.forEach(({ firstName, lastName, house })=>{ + if (house === "Gryffindor") { + console.log(`Task 1 => ${firstName} ${lastName}`); + } +}); + +hogwarts.forEach(({ firstName, lastName, pet, occupation }) => { + if (occupation === "Teacher" && pet != null) { + console.log(`Task 2 => ${firstName} ${lastName}`) + } +}); \ No newline at end of file diff --git a/array-destructuring/exercise-3/exercise.js b/array-destructuring/exercise-3/exercise.js index 0a01f8f0..b77f4c66 100644 --- a/array-destructuring/exercise-3/exercise.js +++ b/array-destructuring/exercise-3/exercise.js @@ -6,3 +6,13 @@ let order = [ { itemName: "Hot Coffee", quantity: 2, unitPrice: 1.0 }, { itemName: "Hash Brown", quantity: 4, unitPrice: 0.4 }, ]; + +let sum = 0; + +order.forEach(({ itemName, quantity, unitPrice }) => { + let total = unitPrice * quantity; + console.log(`For ${quantity} ${itemName} the total price is ${total}`); + sum += total; +}); + +console.log(`Total: ${+sum}`); \ No newline at end of file diff --git a/book-library/index.html b/book-library/index.html index 23acfa71..616188fe 100644 --- a/book-library/index.html +++ b/book-library/index.html @@ -1,96 +1,56 @@ -
-Add books to your virtual library
-Add books to your virtual library
+| Title | +Author | +Number of Pages | +Read | +Delete | +
|---|
| Title | -Author | -Number of Pages | -Read | -- |
|---|---|---|---|---|
| - | - | - | - | - |