From 686f27dbd4697e6c6056716c771565b1979dc226 Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 5 Aug 2026 22:31:11 +0100 Subject: [PATCH 01/11] added the closing parenthesis in the for loop --- .vscode/settings.json | 3 +++ debugging/book-library/script.js | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..6b665aaa --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 75ce6c1d..7f21dc1d 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -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 From 11d4e80899713c6fa058fe7d4665ab32be82c300 Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 5 Aug 2026 22:35:28 +0100 Subject: [PATCH 02/11] used the correct variable name myLibrary inside the submit function --- debugging/book-library/script.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 7f21dc1d..3108e77f 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -38,7 +38,8 @@ function submit() { return false; } else { let book = new Book(title.value, title.value, pages.value, check.checked); - library.push(book); + myLibrary.push(book); + render(); } } From 9acc8841419a9763eff39049bc7914715cfe5b01 Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 5 Aug 2026 22:37:47 +0100 Subject: [PATCH 03/11] added the autho.value by deleting one of the title.value that was passed twice --- debugging/book-library/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 3108e77f..8e45c87e 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -37,7 +37,7 @@ function submit() { alert("Please fill all fields!"); return false; } else { - let book = new Book(title.value, title.value, pages.value, check.checked); + let book = new Book(title.value, author.value, pages.value, check.checked); myLibrary.push(book); render(); From 127e4f435f1a85e8d24c5df3aaeb292d2fe6cf0d Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 5 Aug 2026 22:41:40 +0100 Subject: [PATCH 04/11] changed every instance of delBut with delButton --- debugging/book-library/script.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 8e45c87e..6e6f1e81 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -91,11 +91,11 @@ function render() { //add delete button to every row and render again let delButton = document.createElement("button"); - delBut.id = i + 5; + delButton = i + 5; deleteCell.appendChild(delBut); - delBut.className = "btn btn-warning"; - delBut.innerHTML = "Delete"; - delBut.addEventListener("clicks", function () { + delButton.className = "btn btn-warning"; + delButton.innerHTML = "Delete"; + delButton.addEventListener("clicks", function () { alert(`You've deleted title: ${myLibrary[i].title}`); myLibrary.splice(i, 1); render(); From 8314db5b49b7a9d89e167511e9371edf16a624bb Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 5 Aug 2026 22:43:17 +0100 Subject: [PATCH 05/11] correct the event name by it correct name click --- debugging/book-library/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 6e6f1e81..46e1fabb 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -95,7 +95,7 @@ function render() { deleteCell.appendChild(delBut); delButton.className = "btn btn-warning"; delButton.innerHTML = "Delete"; - delButton.addEventListener("clicks", function () { + delButton.addEventListener("click", function () { alert(`You've deleted title: ${myLibrary[i].title}`); myLibrary.splice(i, 1); render(); From 8c9db43870853b9ef394dbae4675e4a3c7a815d6 Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 5 Aug 2026 22:45:07 +0100 Subject: [PATCH 06/11] changed the wrong logically check from false to yes --- debugging/book-library/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 46e1fabb..2b1fb4a5 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -77,7 +77,7 @@ function render() { changeBut.className = "btn btn-success"; wasReadCell.appendChild(changeBut); let readStatus = ""; - if (myLibrary[i].check == false) { + if (myLibrary[i].check == true) { readStatus = "Yes"; } else { readStatus = "No"; From f839c7baeb75798b14fb65dd65ed4ff2d6ccf282 Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 5 Aug 2026 22:50:05 +0100 Subject: [PATCH 07/11] added additional validation for book's author --- debugging/book-library/script.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 2b1fb4a5..7671d9ff 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -31,6 +31,8 @@ function submit() { if ( title.value == null || title.value == "" || + author.value == null || + author.value == "" || pages.value == null || pages.value == "" ) { @@ -38,7 +40,7 @@ function submit() { return false; } else { let book = new Book(title.value, author.value, pages.value, check.checked); - myLibrary.push(book); + myLibrary.push(book); render(); } From ab117d66a05cdf2b852472420b84597ee7a5bf8e Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 5 Aug 2026 22:53:25 +0100 Subject: [PATCH 08/11] remove the table element from the index.html --- debugging/book-library/index.html | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 23acfa71..8b2308fe 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -80,15 +80,7 @@

Library

- - - - - - - - - + From 55bfed47d842d65e87d3d849ca3a4699dd2a2c23 Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 5 Aug 2026 22:59:04 +0100 Subject: [PATCH 09/11] add the button ID --- debugging/book-library/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 7671d9ff..2529c6b2 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -93,7 +93,7 @@ function render() { //add delete button to every row and render again let delButton = document.createElement("button"); - delButton = i + 5; + delButton.id = i + 5; deleteCell.appendChild(delBut); delButton.className = "btn btn-warning"; delButton.innerHTML = "Delete"; From ab20798e95d88b184211b5f78e68311404b91997 Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 5 Aug 2026 22:59:59 +0100 Subject: [PATCH 10/11] appen the corrent variable name delButton --- debugging/book-library/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 2529c6b2..c1d9ad63 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -94,7 +94,7 @@ function render() { //add delete button to every row and render again let delButton = document.createElement("button"); delButton.id = i + 5; - deleteCell.appendChild(delBut); + deleteCell.appendChild(delButton); delButton.className = "btn btn-warning"; delButton.innerHTML = "Delete"; delButton.addEventListener("click", function () { From 2606f98d6fe1f6fa015733458815ab6c4ff8e550 Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 5 Aug 2026 23:02:40 +0100 Subject: [PATCH 11/11] let the row start to add from top --- .vscode/settings.json | 3 --- debugging/book-library/script.js | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 6b665aaa..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "liveServer.settings.port": 5501 -} diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index c1d9ad63..d706727d 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -63,7 +63,7 @@ function render() { //insert updated row and cells let length = myLibrary.length; for (let i = 0; i < length; i++) { - let row = table.insertRow(1); + let row = table.insertRow(-1); let titleCell = row.insertCell(0); let authorCell = row.insertCell(1); let pagesCell = row.insertCell(2);