From 895c60d12efb3dcbbf787ea05a1413d409960237 Mon Sep 17 00:00:00 2001 From: areebsattar Date: Fri, 2 Feb 2024 22:36:36 +0000 Subject: [PATCH 1/7] Fixed a few bugs --- book-library/index.html | 2 +- book-library/script.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/book-library/index.html b/book-library/index.html index 23acfa71..c24317a6 100644 --- a/book-library/index.html +++ b/book-library/index.html @@ -1,7 +1,7 @@ - + Book Library 0; n-- { + for (let n = rowsNumber - 1; n > 0; n--) { table.deleteRow(n); } //insert updated row and cells @@ -89,7 +89,7 @@ function render() { }); //add delete button to every row and render again - let delButton = document.createElement("button"); + let delBut = document.createElement("button"); delBut.id = i + 5; cell5.appendChild(delBut); delBut.className = "btn btn-warning"; From a8d2cd696729f7a08460b9775e598285e097f857 Mon Sep 17 00:00:00 2001 From: areebsattar Date: Fri, 2 Feb 2024 22:59:04 +0000 Subject: [PATCH 2/7] Fixed all the bugs --- book-library/index.html | 136 ++++++++++++++-------------------------- book-library/script.js | 9 +-- 2 files changed, 50 insertions(+), 95 deletions(-) diff --git a/book-library/index.html b/book-library/index.html index c24317a6..616188fe 100644 --- a/book-library/index.html +++ b/book-library/index.html @@ -1,96 +1,56 @@ - - Book Library - - - - - - - - -
-

Library

-

Add books to your virtual library

-
+ + Book Library + + + + + + + + + +
+

Library

+

Add books to your virtual library

+
- + -
-
- - - - - - - - -
+
+
+ + + + + + + +
+
+ + + + + + + + + + + + + +
TitleAuthorNumber of PagesReadDelete
- - - - - - - - - - - - - - - - - - - -
TitleAuthorNumber of PagesRead
+ + - - - + \ No newline at end of file diff --git a/book-library/script.js b/book-library/script.js index 7bd8276f..5de94a30 100644 --- a/book-library/script.js +++ b/book-library/script.js @@ -75,12 +75,7 @@ function render() { changeBut.id = i; changeBut.className = "btn btn-success"; cell4.appendChild(changeBut); - let readStatus = ""; - if (myLibrary[i].check == false) { - readStatus = "Yes"; - } else { - readStatus = "No"; - } + let readStatus = myLibrary[i].check ? "No" : "Yes"; changeBut.innerHTML = readStatus; changeBut.addEventListener("click", function () { @@ -94,7 +89,7 @@ function render() { cell5.appendChild(delBut); delBut.className = "btn btn-warning"; delBut.innerHTML = "Delete"; - delBut.addEventListener("clicks", function () { + delBut.addEventListener("click", function () { alert(`You've deleted title: ${myLibrary[i].title}`); myLibrary.splice(i, 1); render(); From 802c06d4dc90d950064344fc2c92b58471f94570 Mon Sep 17 00:00:00 2001 From: areebsattar Date: Sat, 17 Feb 2024 12:00:16 +0000 Subject: [PATCH 3/7] completed 2 excercises --- array-destructuring/exercise-1/exercise.js | 6 ++++-- array-destructuring/exercise-2/exercise.js | 13 +++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) 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 From 905a6bc59e792b504a7121100875d5cf11e29cb8 Mon Sep 17 00:00:00 2001 From: areebsattar Date: Sat, 17 Feb 2024 14:08:18 +0000 Subject: [PATCH 4/7] all excercises completed --- array-destructuring/exercise-3/exercise.js | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 From 38403fb5df14501ab344bb594b6e533360b32997 Mon Sep 17 00:00:00 2001 From: areebsattar Date: Sun, 18 Feb 2024 23:59:52 +0000 Subject: [PATCH 5/7] task completed --- programmer-humour/index.html | 18 ++++++++++++++++++ programmer-humour/script.js | 17 +++++++++++++++++ programmer-humour/styles.css | 12 ++++++++++++ 3 files changed, 47 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..935ff722 --- /dev/null +++ b/programmer-humour/index.html @@ -0,0 +1,18 @@ + + + + + + + + + Programmer humour + + + + image for comic + +
+ + + \ No newline at end of file diff --git a/programmer-humour/script.js b/programmer-humour/script.js new file mode 100644 index 00000000..23797993 --- /dev/null +++ b/programmer-humour/script.js @@ -0,0 +1,17 @@ +const comicImage = document.getElementById("comic-image"); +async function fetchComic() { + fetch("https://xkcd.now.sh/?comic=latest").then((response) => { + if (!response.ok) { + throw new Error("Can't get data"); + } + return response.json(); + }) + .then((comic) => { + console.log(comic); + comicImage.src = comic.img + }).catch((error) => { + console.error("Error fetching image"); +}) +} + +fetchComic(); \ No newline at end of file diff --git a/programmer-humour/styles.css b/programmer-humour/styles.css new file mode 100644 index 00000000..63dcb14b --- /dev/null +++ b/programmer-humour/styles.css @@ -0,0 +1,12 @@ +body{ + background-color: aliceblue; +} + +#comic-image { + max-width: 100%; + height: auto; + display: block; + margin: 20px auto; + border: 1px solid #ddd; + box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); +} \ No newline at end of file From 19b96d008b0ce4405ad9e7e030814f9ae2692060 Mon Sep 17 00:00:00 2001 From: areebsattar Date: Mon, 19 Feb 2024 00:05:29 +0000 Subject: [PATCH 6/7] Update because of pushing last changes to wrong pull request --- programmer-humour/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programmer-humour/index.html b/programmer-humour/index.html index 935ff722..f5927b26 100644 --- a/programmer-humour/index.html +++ b/programmer-humour/index.html @@ -10,7 +10,7 @@ - image for comic + image for comic fetched
From 016e09ed73701255386e9c1b4d08567ba737b9f0 Mon Sep 17 00:00:00 2001 From: areebsattar Date: Mon, 19 Feb 2024 00:15:18 +0000 Subject: [PATCH 7/7] removed previous files from array destructuring --- array-destructuring/exercise-1/exercise.js | 9 --------- array-destructuring/exercise-2/exercise.js | 11 ----------- array-destructuring/exercise-3/exercise.js | 10 ---------- 3 files changed, 30 deletions(-) diff --git a/array-destructuring/exercise-1/exercise.js b/array-destructuring/exercise-1/exercise.js index e62de539..9ac2cfd9 100644 --- a/array-destructuring/exercise-1/exercise.js +++ b/array-destructuring/exercise-1/exercise.js @@ -4,12 +4,3 @@ const personOne = { favouriteFood: "Spinach", }; -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(); diff --git a/array-destructuring/exercise-2/exercise.js b/array-destructuring/exercise-2/exercise.js index e4ea595b..43092858 100644 --- a/array-destructuring/exercise-2/exercise.js +++ b/array-destructuring/exercise-2/exercise.js @@ -72,14 +72,3 @@ let hogwarts = [ ]; -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 b77f4c66..0a01f8f0 100644 --- a/array-destructuring/exercise-3/exercise.js +++ b/array-destructuring/exercise-3/exercise.js @@ -6,13 +6,3 @@ 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