From c40984aa526b10b9051b026593f09c380fe29009 Mon Sep 17 00:00:00 2001 From: Fathi Kahin <127356471+fhkahin@users.noreply.github.com> Date: Wed, 14 Feb 2024 12:22:51 +0000 Subject: [PATCH 1/6] exercise.js updated --- array-destructuring/exercise-1/exercise.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/array-destructuring/exercise-1/exercise.js b/array-destructuring/exercise-1/exercise.js index a6eab299..6ebaae44 100644 --- a/array-destructuring/exercise-1/exercise.js +++ b/array-destructuring/exercise-1/exercise.js @@ -4,10 +4,8 @@ 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}.` ); } - -introduceYourself(personOne); From 90810bb8365f0acafc5271c940e28c5522645e66 Mon Sep 17 00:00:00 2001 From: Fathi Kahin <127356471+fhkahin@users.noreply.github.com> Date: Wed, 14 Feb 2024 12:24:43 +0000 Subject: [PATCH 2/6] exercise 2 ompleted --- array-destructuring/exercise-2/exercise.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/array-destructuring/exercise-2/exercise.js b/array-destructuring/exercise-2/exercise.js index e11b75eb..47c6453a 100644 --- a/array-destructuring/exercise-2/exercise.js +++ b/array-destructuring/exercise-2/exercise.js @@ -70,3 +70,20 @@ let hogwarts = [ occupation: "Teacher", }, ]; + + +// Task 1 +console.log("Task 1:"); +hogwarts.forEach(({ firstName, lastName, house }) => { + if (house === "Gryffindor") { + console.log(`${firstName} ${lastName}`); + } +}); + +// Task 2 +console.log("\nTask 2:"); +hogwarts.forEach(({ firstName, lastName, occupation, pet }) => { + if (occupation === "Teacher" && pet) { + console.log(`${firstName} ${lastName}`); + } +}); From 7463459e9bee77ca6d5b081074b12b2dabfb0519 Mon Sep 17 00:00:00 2001 From: Fathi Kahin <127356471+fhkahin@users.noreply.github.com> Date: Wed, 14 Feb 2024 12:25:52 +0000 Subject: [PATCH 3/6] exercise3 completed --- array-destructuring/exercise-3/exercise.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/array-destructuring/exercise-3/exercise.js b/array-destructuring/exercise-3/exercise.js index 0a01f8f0..c51576d9 100644 --- a/array-destructuring/exercise-3/exercise.js +++ b/array-destructuring/exercise-3/exercise.js @@ -6,3 +6,14 @@ let order = [ { itemName: "Hot Coffee", quantity: 2, unitPrice: 1.0 }, { itemName: "Hash Brown", quantity: 4, unitPrice: 0.4 }, ]; + +console.log("QUANTITY ITEM TOTAL"); +let totalCost = 0; + +order.forEach(({ itemName, quantity, unitPrice }) => { + let totalItemPrice = quantity * unitPrice; + totalCost += totalItemPrice; + console.log(`${quantity}\t${itemName.padEnd(20)}${totalItemPrice.toFixed(2)}`); +}); + +console.log(`\nTotal: ${totalCost.toFixed(2)}`); From 95ce14f1b5c0a79d769311a64c4cb5fe03470abf Mon Sep 17 00:00:00 2001 From: Fathi Kahin <127356471+fhkahin@users.noreply.github.com> Date: Wed, 14 Feb 2024 13:22:29 +0000 Subject: [PATCH 4/6] index.html completed --- programmer-humour/index.html | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 programmer-humour/index.html diff --git a/programmer-humour/index.html b/programmer-humour/index.html new file mode 100644 index 00000000..14990ee8 --- /dev/null +++ b/programmer-humour/index.html @@ -0,0 +1,23 @@ + + + + + + + XKCD Comic Viewer + + + + +
+

+
+ XKCD Comic +
+

+

+
+ + + + From bd7c5ebec5db47860c335f31f7d2479812f7d4e1 Mon Sep 17 00:00:00 2001 From: Fathi Kahin <127356471+fhkahin@users.noreply.github.com> Date: Wed, 14 Feb 2024 13:25:12 +0000 Subject: [PATCH 5/6] script.js completed --- programmer-humour/script.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 programmer-humour/script.js diff --git a/programmer-humour/script.js b/programmer-humour/script.js new file mode 100644 index 00000000..4cb26d5f --- /dev/null +++ b/programmer-humour/script.js @@ -0,0 +1,33 @@ +const titleElement = document.getElementById("title"); +const comicImageElement = document.getElementById("comic-img"); +const dateElement = document.getElementById("date"); +const comicNumberElement = document.getElementById("comic-number"); + +// Function to fetch and display XKCD comic +function fetchXKCDComic() { + fetch("https://xkcd.now.sh/?comic=latest") + .then(response => response.json()) + .then(data => { + // Logging the data to the console + console.log(data); + + // Setting the comic title + titleElement.textContent = data.title; + + // Setting the comic image source + comicImageElement.src = data.img; + + // Setting the comic publication date + dateElement.textContent = `Published on ${data.month}/${data.day}`; + + // Setting the comic number + comicNumberElement.textContent = `Comic Number: ${data.num}`; + }) + .catch(error => { + console.error("Error fetching XKCD comic:", error); + titleElement.textContent = "Error fetching comic"; + }); +} + +// Calling the function to fetch and display XKCD comic +fetchXKCDComic(); From 6842ffdce4bf1de94c3f1c67fcf32b3b52cd5e04 Mon Sep 17 00:00:00 2001 From: Fathi Kahin <127356471+fhkahin@users.noreply.github.com> Date: Wed, 14 Feb 2024 13:27:44 +0000 Subject: [PATCH 6/6] style.css added --- programmer-humour/style.css | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 programmer-humour/style.css diff --git a/programmer-humour/style.css b/programmer-humour/style.css new file mode 100644 index 00000000..ffae3853 --- /dev/null +++ b/programmer-humour/style.css @@ -0,0 +1,36 @@ +body { + font-family: 'Comic Sans MS', sans-serif; + background-color: #f0f0f0; + margin: 0; + padding: 0; + text-align: center; +} + +#root { + max-width: 800px; + margin: 20px auto; + padding: 20px; + background-color: #fff; + border-radius: 10px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); +} + +h1 { + color: #ff5722; +} + +#comic-container { + margin-top: 20px; +} + +#comic-img { + max-width: 100%; + height: auto; + border-radius: 10px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.2); +} + +#date, #comic-number { + color: #666; + margin-top: 10px; +}