diff --git a/array-destructuring/exercise-1/exercise.js b/array-destructuring/exercise-1/exercise.js index a6eab299..9ac2cfd9 100644 --- a/array-destructuring/exercise-1/exercise.js +++ b/array-destructuring/exercise-1/exercise.js @@ -4,10 +4,3 @@ const personOne = { favouriteFood: "Spinach", }; -function introduceYourself(___________________________) { - console.log( - `Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.` - ); -} - -introduceYourself(personOne); diff --git a/array-destructuring/exercise-2/exercise.js b/array-destructuring/exercise-2/exercise.js index e11b75eb..43092858 100644 --- a/array-destructuring/exercise-2/exercise.js +++ b/array-destructuring/exercise-2/exercise.js @@ -70,3 +70,5 @@ let hogwarts = [ occupation: "Teacher", }, ]; + + 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 @@ - - - - - - - - - - -
-

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 dc14a775..5de94a30 100644 --- a/book-library/script.js +++ b/book-library/script.js @@ -37,8 +37,8 @@ function submit() { alert("Please fill all fields!"); return false; } else { - let book = new Book(title.value, title.value, pages.value, check.checked); - library.push(book); + let book = new Book(title.value, author.value, pages.value, check.checked); + myLibrary.push(book); render(); } } @@ -54,7 +54,7 @@ function render() { let table = document.getElementById("display"); let rowsNumber = table.rows.length; //delete old table - for (let n = rowsNumber - 1; n > 0; n-- { + for (let n = rowsNumber - 1; n > 0; n--) { table.deleteRow(n); } //insert updated row and cells @@ -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 () { @@ -89,12 +84,12 @@ 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"; delBut.innerHTML = "Delete"; - delBut.addEventListener("clicks", function () { + delBut.addEventListener("click", function () { alert(`You've deleted title: ${myLibrary[i].title}`); myLibrary.splice(i, 1); render(); diff --git a/programmer-humour/index.html b/programmer-humour/index.html new file mode 100644 index 00000000..f5927b26 --- /dev/null +++ b/programmer-humour/index.html @@ -0,0 +1,18 @@ + + + + + + + + + Programmer humour + + + + image for comic fetched + + + + + \ 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