From e4c77256cc90ef35733aa7cdb5eff62688ebb9f4 Mon Sep 17 00:00:00 2001 From: RbAvci Date: Mon, 12 Feb 2024 20:14:50 +0000 Subject: [PATCH 1/8] destructure exercise-1 --- array-destructuring/exercise-1/exercise.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/array-destructuring/exercise-1/exercise.js b/array-destructuring/exercise-1/exercise.js index a6eab299..e996e93b 100644 --- a/array-destructuring/exercise-1/exercise.js +++ b/array-destructuring/exercise-1/exercise.js @@ -1,10 +1,11 @@ + const personOne = { name: "Popeye", age: 34, 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 911d2f838b5a64fedfd997dbcfa36760a33b68b1 Mon Sep 17 00:00:00 2001 From: RbAvci Date: Mon, 12 Feb 2024 20:32:30 +0000 Subject: [PATCH 2/8] destructure exercise-2 --- array-destructuring/exercise-2/exercise.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/array-destructuring/exercise-2/exercise.js b/array-destructuring/exercise-2/exercise.js index e11b75eb..b6ab5017 100644 --- a/array-destructuring/exercise-2/exercise.js +++ b/array-destructuring/exercise-2/exercise.js @@ -70,3 +70,13 @@ let hogwarts = [ occupation: "Teacher", }, ]; + +console.log('The names of the people who belong to the Gryffindor house:') + +hogwarts.filter(({house}) => house === "Gryffindor") +.forEach(({firstName,lastName}) => console.log(`${firstName} ${lastName}`)); + +console.log('The names of teachers who have pets:') + +hogwarts.filter(({pet,occupation})=> pet !== null && occupation === "Teacher" ) +.forEach(({firstName,lastName}) => console.log(`${firstName} ${lastName}`)); From e94e7281a1a486304d1482bbdd6b5f4bd3c0dc2a Mon Sep 17 00:00:00 2001 From: RbAvci Date: Mon, 12 Feb 2024 21:09:49 +0000 Subject: [PATCH 3/8] destructure exercise-3 --- array-destructuring/exercise-3/exercise.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/array-destructuring/exercise-3/exercise.js b/array-destructuring/exercise-3/exercise.js index 0a01f8f0..a9d8eb33 100644 --- a/array-destructuring/exercise-3/exercise.js +++ b/array-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 formatPrice(price) { + return price.toFixed(2); +} + +console.log("QTY\tITEM\t\t\tTOTAL"); + +let total = 0; + +for (const {quantity, itemName, unitPrice} of order) { + console.log(`${quantity}\t${itemName}\t\t${(unitPrice * quantity).toFixed(2)}`); + total += unitPrice * quantity; +} + +console.log("\nTotal:", formatPrice(total)); + From 3daf9a7b667ce00b3b3b439cacd04dc111ddad6e Mon Sep 17 00:00:00 2001 From: RbAvci Date: Mon, 25 Mar 2024 11:29:25 +0000 Subject: [PATCH 4/8] Create html css js --- programmer-humour/index.html | 14 ++++++++++++++ programmer-humour/script.js | 0 programmer-humour/styles.css | 0 3 files changed, 14 insertions(+) create mode 100644 programmer-humour/index.html create mode 100644 programmer-humour/script.js create mode 100644 programmer-humour/styles.css diff --git a/programmer-humour/index.html b/programmer-humour/index.html new file mode 100644 index 00000000..03c1ba81 --- /dev/null +++ b/programmer-humour/index.html @@ -0,0 +1,14 @@ + + + + + + + Programmer Humour + + + + + + + \ No newline at end of file diff --git a/programmer-humour/script.js b/programmer-humour/script.js new file mode 100644 index 00000000..e69de29b diff --git a/programmer-humour/styles.css b/programmer-humour/styles.css new file mode 100644 index 00000000..e69de29b From d50128b9b502013d6b874a2a5aca858f56ff0b1c Mon Sep 17 00:00:00 2001 From: RbAvci Date: Mon, 25 Mar 2024 11:41:37 +0000 Subject: [PATCH 5/8] add fetch function to get data --- programmer-humour/index.html | 8 +++++++- programmer-humour/script.js | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/programmer-humour/index.html b/programmer-humour/index.html index 03c1ba81..ad87199f 100644 --- a/programmer-humour/index.html +++ b/programmer-humour/index.html @@ -5,10 +5,16 @@ Programmer Humour + + - +
+

xkcd Comic Viewer

+
+
+
\ No newline at end of file diff --git a/programmer-humour/script.js b/programmer-humour/script.js index e69de29b..7ee6d0fa 100644 --- a/programmer-humour/script.js +++ b/programmer-humour/script.js @@ -0,0 +1,18 @@ +function fetchComic() { + fetch("https://xkcd.now.sh/?comic=latest") + .then((response) => response.json()) + .then((data) => { + console.log(data); + + const comicContainer = document.getElementById("comicContainer"); + const imgElement = document.createElement("img"); + imgElement.src = data.img; + imgElement.alt = data.alt; + comicContainer.appendChild(imgElement); + }) + .catch((error) => console.error("Error fetching comic:", error)); +} + +document.addEventListener("DOMContentLoaded", function () { + fetchComic(); +}); From 4620836c9501f8f49d5acff61567733544ccf6a5 Mon Sep 17 00:00:00 2001 From: RbAvci Date: Mon, 25 Mar 2024 11:41:50 +0000 Subject: [PATCH 6/8] add sytling --- programmer-humour/styles.css | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/programmer-humour/styles.css b/programmer-humour/styles.css index e69de29b..28330768 100644 --- a/programmer-humour/styles.css +++ b/programmer-humour/styles.css @@ -0,0 +1,25 @@ +body { + font-family: Arial, sans-serif; + margin: 20px; +} + +.container { + max-width: 800px; + margin: 0 auto; + text-align: center; +} + +h1 { + color: #c24242; + +} + +img { + max-width: 100%; + height: auto; + margin-top: 20px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + background-color: #c24242; + padding: 2rem; + +} \ No newline at end of file From 3614e1b9f1f48bbadd45d3165b0f0d1f27d99f53 Mon Sep 17 00:00:00 2001 From: RbAvci Date: Mon, 25 Mar 2024 13:14:42 +0000 Subject: [PATCH 7/8] add footer and styling --- programmer-humour/index.html | 7 +++++++ programmer-humour/script.js | 8 ++++---- programmer-humour/styles.css | 17 +++++++++++++++-- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/programmer-humour/index.html b/programmer-humour/index.html index ad87199f..59e3165b 100644 --- a/programmer-humour/index.html +++ b/programmer-humour/index.html @@ -14,7 +14,14 @@

xkcd Comic Viewer

+
+

Comic made by Randall Munroe from xkcd.com

+

page by Rabia AVCI GitHub +

+
+ + \ No newline at end of file diff --git a/programmer-humour/script.js b/programmer-humour/script.js index 7ee6d0fa..37181324 100644 --- a/programmer-humour/script.js +++ b/programmer-humour/script.js @@ -1,3 +1,7 @@ +document.addEventListener("DOMContentLoaded", function () { + fetchComic(); +}); + function fetchComic() { fetch("https://xkcd.now.sh/?comic=latest") .then((response) => response.json()) @@ -12,7 +16,3 @@ function fetchComic() { }) .catch((error) => console.error("Error fetching comic:", error)); } - -document.addEventListener("DOMContentLoaded", function () { - fetchComic(); -}); diff --git a/programmer-humour/styles.css b/programmer-humour/styles.css index 28330768..c9f1b658 100644 --- a/programmer-humour/styles.css +++ b/programmer-humour/styles.css @@ -10,16 +10,29 @@ body { } h1 { - color: #c24242; + color: aliceblue; + padding: 1px; + max-width: 100%; + padding: 10px; + background-color: #c24242; } img { max-width: 100%; height: auto; - margin-top: 20px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); background-color: #c24242; padding: 2rem; +} + +footer { + color: aliceblue; + padding: 1px; + max-width: 100%; + border: solid 2px #c24242; + margin-top: 10px; + background-color: #c24242; + } \ No newline at end of file From 2495a8f92875d342e02df081859eadfd52720188 Mon Sep 17 00:00:00 2001 From: RbAvci Date: Mon, 25 Mar 2024 14:19:12 +0000 Subject: [PATCH 8/8] fix sonar build errors --- programmer-humour/index.html | 5 +++-- programmer-humour/styles.css | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/programmer-humour/index.html b/programmer-humour/index.html index 59e3165b..8f3e8c59 100644 --- a/programmer-humour/index.html +++ b/programmer-humour/index.html @@ -15,8 +15,9 @@

xkcd Comic Viewer

diff --git a/programmer-humour/styles.css b/programmer-humour/styles.css index c9f1b658..f838d55b 100644 --- a/programmer-humour/styles.css +++ b/programmer-humour/styles.css @@ -11,7 +11,6 @@ body { h1 { color: aliceblue; - padding: 1px; max-width: 100%; padding: 10px; background-color: #c24242;