From 580571e223e1ceede80f0186158aa7c3e8a082ee Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Sat, 15 Aug 2026 04:08:31 +0100 Subject: [PATCH 1/9] adding missing parenthesis at 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..eed706fdc 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 1c3aa6758a27b3a77ea291693f0797fd9a422cfc Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Sat, 15 Aug 2026 04:16:30 +0100 Subject: [PATCH 2/9] Fixed issues in the submit() function that prevented new books from being added correctly. --- debugging/book-library/script.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index eed706fdc..3c1e32d24 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -29,20 +29,20 @@ const check = document.getElementById("check"); //via Book function and start render function function submit() { if ( - title.value == null || title.value == "" || - pages.value == null || + author.value == "" || pages.value == "" ) { alert("Please fill all fields!"); - return false; - } else { - let book = new Book(title.value, title.value, pages.value, check.checked); - library.push(book); - render(); + return; } + + let book = new Book(title.value, author.value, pages.value, check.checked); + myLibrary.push(book); + render(); } + function Book(title, author, pages, check) { this.title = title; this.author = author; From c9da8fd4034f6e05e586442304e64957afe8c279 Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Sat, 15 Aug 2026 04:24:47 +0100 Subject: [PATCH 3/9] Corrected the read/unread display logic and fixed the broken delete button in the library table --- debugging/book-library/script.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 3c1e32d24..c412f12a1 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -28,11 +28,7 @@ const check = document.getElementById("check"); //check the right input from forms and if its ok -> add the new book (object in array) //via Book function and start render function function submit() { - if ( - title.value == "" || - author.value == "" || - pages.value == "" - ) { + if (title.value == "" || author.value == "" || pages.value == "") { alert("Please fill all fields!"); return; } @@ -42,7 +38,6 @@ function submit() { render(); } - function Book(title, author, pages, check) { this.title = title; this.author = author; @@ -76,11 +71,12 @@ 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"; } + changeBut.innerText = readStatus; changeBut.addEventListener("click", function () { @@ -88,13 +84,14 @@ function render() { render(); }); - //add delete button to every row and render again + // add delete button to every row and render again let delButton = document.createElement("button"); - delBut.id = i + 5; - deleteCell.appendChild(delBut); - delBut.className = "btn btn-warning"; - delBut.innerHTML = "Delete"; - delBut.addEventListener("clicks", function () { + delButton.id = i + 5; + deleteCell.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(); From dd59bc5421cc9e3c9d2628418bdf8056fa77cbfe Mon Sep 17 00:00:00 2001 From: Jacknguyen4438 Date: Sat, 15 Aug 2026 16:19:09 +0100 Subject: [PATCH 4/9] Making error fix based from HTML validation checker --- debugging/book-library/index.html | 22 ++++++++++------------ debugging/book-library/script.js | 3 ++- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 23acfa71e..4885ed88a 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -1,12 +1,10 @@ - + - - + Online book library + + + @@ -31,19 +29,19 @@

Library

Library class="form-control" id="pages" name="pages" - required + />