From ee2cff998a90d8bb2d39ba0798228869d6d725c8 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 20 Aug 2026 15:29:22 +0100 Subject: [PATCH 1/9] fix syntax error on line 57 --- 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 75ce6c1d3..daef66a6c 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--) { // there was a syntax error here the ")" was missing table.deleteRow(n); } //insert updated row and cells From 6bed9db92ca76b9b16a62d00407dfdf27dbd33d5 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 20 Aug 2026 15:39:32 +0100 Subject: [PATCH 2/9] on line 41 not 'library', 'myLibrary', and 'title.value' is repeated --- debugging/book-library/script.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index daef66a6c..b7b315e9d 100644 --- a/debugging/book-library/script.js +++ b/debugging/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,8 @@ function render() { let table = document.getElementById("display"); let rowsNumber = table.rows.length; //delete old table - for (let n = rowsNumber - 1; n > 0; n--) { // there was a syntax error here the ")" was missing + for (let n = rowsNumber - 1; n > 0; n--) { + // there was a syntax error here the ")" was missing table.deleteRow(n); } //insert updated row and cells From 44d9deaaaac8c0e3b4de3e70c33751398e078bf4 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 20 Aug 2026 15:44:59 +0100 Subject: [PATCH 3/9] deleteButton was inconsistent variable, change to deleteBut, change clicks to click --- debugging/book-library/script.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index b7b315e9d..d0a077657 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -90,12 +90,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; deleteCell.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 a963df2106035f4b2c680606723a1c84230acf12 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 20 Aug 2026 16:12:18 +0100 Subject: [PATCH 4/9] add , and lang='en' --- debugging/book-library/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 23acfa71e..4a08467da 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -1,7 +1,7 @@ <!DOCTYPE html> -<html> +<html lang="en"> <head> - <title> + My Book Library Date: Thu, 20 Aug 2026 16:29:28 +0100 Subject: [PATCH 5/9] fix , add extra --- debugging/book-library/index.html | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 4a08467da..a268ce29b 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -3,10 +3,9 @@ My Book Library + charset="utf-8" /> + + @@ -90,7 +89,6 @@

Library

- - + - + \ No newline at end of file From 50a35c6882346727d0496a4201c5e78a716c6dd9 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 20 Aug 2026 16:41:57 +0100 Subject: [PATCH 6/9] add defer to sccript links --- debugging/book-library/index.html | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index a268ce29b..aff92f531 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -5,10 +5,11 @@ - - - - + + + + Library

Add books to your virtual library

- @@ -30,7 +31,7 @@

Library

Date: Thu, 20 Aug 2026 16:50:28 +0100 Subject: [PATCH 7/9] add main tag --- debugging/book-library/index.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index aff92f531..8bcc4dc61 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -18,6 +18,7 @@ +

Library

Add books to your virtual library

@@ -39,7 +40,7 @@

Library

/> Library +
\ No newline at end of file From 2073970a7ca2a337a585b973d48f00bfb724d3f6 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 20 Aug 2026 17:24:04 +0100 Subject: [PATCH 8/9] add author validation conditions, --- debugging/book-library/script.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index d0a077657..f307a609d 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -29,6 +29,8 @@ const check = document.getElementById("check"); //via Book function and start render function function submit() { if ( + author.value == null || + author.value == "" || title.value == null || title.value == "" || pages.value == null || @@ -61,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); @@ -77,7 +79,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 8ad66175bd4e83e378bb713cbe305254154d3661 Mon Sep 17 00:00:00 2001 From: vmoratti Date: Thu, 20 Aug 2026 22:17:26 +0100 Subject: [PATCH 9/9] change delete button details --- debugging/book-library/script.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index f307a609d..6618deb56 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -98,9 +98,14 @@ function render() { delBut.className = "btn btn-warning"; delBut.innerHTML = "Delete"; delBut.addEventListener("click", function () { - alert(`You've deleted title: ${myLibrary[i].title}`); + const deletedTitle = myLibrary[i].title; + myLibrary.splice(i, 1); render(); + + setTimeout(function () { + alert(`You've deleted title: ${deletedTitle}`); + }, 0.5); }); } }