diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 00000000..6f3a2913
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "liveServer.settings.port": 5501
+}
\ No newline at end of file
diff --git a/book-library/script.js b/book-library/script.js
index dc14a775..7120a4d6 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
@@ -90,11 +90,11 @@ function render() {
//add delete button to every row and render again
let delButton = document.createElement("button");
- delBut.id = i + 5;
- cell5.appendChild(delBut);
- delBut.className = "btn btn-warning";
- delBut.innerHTML = "Delete";
- delBut.addEventListener("clicks", function () {
+ delButton.id = i + 5;
+ cell5.appendChild(delButton);
+ delButton.className = "btn btn-warning";
+ delButton.innerHTML = "Delete";
+ delButton.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..219a3769
--- /dev/null
+++ b/programmer-humour/index.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+ Programming humour
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/programmer-humour/index.js b/programmer-humour/index.js
new file mode 100644
index 00000000..e9eb4d57
--- /dev/null
+++ b/programmer-humour/index.js
@@ -0,0 +1,21 @@
+
+const getImages = async () => {
+
+ return fetch('https://xkcd.now.sh/?comic=latest').then((data) => {
+ const response = data.json();
+ return response;
+ }).catch(error => {
+ console.error('Fetch error:', error);
+ });
+
+}
+
+function render() {
+ getImages().then((data) => {
+ const img = document.createElement('img');
+ img.src = data.img;
+ document.querySelector('#container').appendChild(img);
+
+ })
+}
+window.onload = render;
\ No newline at end of file
diff --git a/programmer-humour/readme.md b/programmer-humour/readme.md
index 2de3faaf..af25c351 100644
--- a/programmer-humour/readme.md
+++ b/programmer-humour/readme.md
@@ -1,13 +1,13 @@
-# Programmer humour
-
-Who knew programmers could be funny?
-
-Write an function that makes an API call to `https://xkcd.now.sh/?comic=latest`
-
-1. Create a `HTML`, `CSS` and `JavaScript` file to write your code in
-
-- Inside the same file write a program that gets the `json` using Fetch.
-- A function should make an API call to the given endpoint: `https://xkcd.now.sh/?comic=latest`
-- Log the received data to the console
-- Render the `img` property into an `` tag in the DOM
-- Incorporate error handling
+# Programmer humour
+
+Who knew programmers could be funny?
+
+Write an function that makes an API call to `https://xkcd.now.sh/?comic=latest`
+
+1. Create a `HTML`, `CSS` and `JavaScript` file to write your code in
+
+- Inside the same file write a program that gets the `json` using Fetch.
+- A function should make an API call to the given endpoint: `https://xkcd.now.sh/?comic=latest`
+- Log the received data to the console
+- Render the `img` property into an `` tag in the DOM
+- Incorporate error handling
diff --git a/programmer-humour/style.css b/programmer-humour/style.css
new file mode 100644
index 00000000..0629fe24
--- /dev/null
+++ b/programmer-humour/style.css
@@ -0,0 +1,5 @@
+body {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+}
\ No newline at end of file