From f2d96ec9fd9b91a20847c64d42ce7b42385b22bc Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 26 Nov 2026 13:33:34 +0000 Subject: [PATCH 01/15] Fix syntax error in render function for loop by closing parenthesis --- 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 e923a606d868ac4ccef888466c1c73c5eb5bfabf Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 26 Nov 2026 13:50:35 +0000 Subject: [PATCH 02/15] Rename delete button variable for clarity in render function --- 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 eed706fdc..abcd4293d 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -89,7 +89,7 @@ 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"; From 14bc0185e9477429b89353355005d180cc00e97f Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 26 Nov 2026 13:55:04 +0000 Subject: [PATCH 03/15] Fix variable name from 'library' to 'myLibrary' in submit function --- 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 abcd4293d..19c53ac2c 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -38,7 +38,7 @@ 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 78543486a663aec1d93c869af55dfb35c7118866 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 26 Nov 2026 13:56:38 +0000 Subject: [PATCH 04/15] Fix author value assignment in book creation in submit function --- 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 19c53ac2c..f95d08875 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 24e560a5af9b25bde7d07a98f377e37e880f1150 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 26 Nov 2026 14:13:50 +0000 Subject: [PATCH 05/15] Validate author input in submit function --- debugging/book-library/script.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index f95d08875..d22c89873 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 == "" ) { From 9b4f68fa4e5a50b4c2257e63f2a265ac81dfd6fd Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 26 Nov 2026 14:32:56 +0000 Subject: [PATCH 06/15] Simplify read status check in render function --- 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 d22c89873..71559d294 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -78,7 +78,7 @@ function render() { changeBut.className = "btn btn-success"; wasReadCell.appendChild(changeBut); let readStatus = ""; - if (myLibrary[i].check == false) { + if (myLibrary[i].check) { readStatus = "Yes"; } else { readStatus = "No"; From 9bc3567bc94971b685f492e19cf541147b843538 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 26 Nov 2026 14:52:02 +0000 Subject: [PATCH 07/15] Fix event listener typo for delete button in render function --- 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 71559d294..be5d0646a 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -96,7 +96,7 @@ function render() { 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 bf88856512e7d1b8285efc1a57ac4c47c99561c3 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 26 Nov 2026 15:02:56 +0000 Subject: [PATCH 08/15] Remove unnecessary ID assignment for read/unread button in render function --- debugging/book-library/script.js | 1 - 1 file changed, 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index be5d0646a..93b1f78d7 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -74,7 +74,6 @@ function render() { //add and wait for action for read/unread button let changeBut = document.createElement("button"); - changeBut.id = i; changeBut.className = "btn btn-success"; wasReadCell.appendChild(changeBut); let readStatus = ""; From 21b9f78ab2c55eb9e8f851b2fef30e6b975a0139 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 26 Nov 2026 15:03:14 +0000 Subject: [PATCH 09/15] Remove unnecessary ID assignment for delete button in render function --- debugging/book-library/script.js | 1 - 1 file changed, 1 deletion(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 93b1f78d7..3366d5554 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -91,7 +91,6 @@ function render() { //add delete button to every row and render again let delBut = document.createElement("button"); - delBut.id = i + 5; deleteCell.appendChild(delBut); delBut.className = "btn btn-warning"; delBut.innerHTML = "Delete"; From 65fcbae9ac4bea2128ee5ecf7e4313596b8603e9 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 26 Nov 2026 15:57:41 +0000 Subject: [PATCH 10/15] Fix validation check for pages input in submit function --- 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 3366d5554..b6b70c6c5 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -34,7 +34,7 @@ function submit() { author.value == null || author.value == "" || pages.value == null || - pages.value == "" + pages.value < 1 ) { alert("Please fill all fields!"); return false; From bb3c812e9153af07827dc81c547a15d1466ffd95 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 26 Nov 2026 16:02:09 +0000 Subject: [PATCH 11/15] Use textContent instead of innerHTML for rendering book details in the table --- debugging/book-library/script.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index b6b70c6c5..c5336be8e 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -68,9 +68,9 @@ function render() { let pagesCell = row.insertCell(2); let wasReadCell = row.insertCell(3); let deleteCell = row.insertCell(4); - titleCell.innerHTML = myLibrary[i].title; - authorCell.innerHTML = myLibrary[i].author; - pagesCell.innerHTML = myLibrary[i].pages; + titleCell.textContent = myLibrary[i].title; + authorCell.textContent = myLibrary[i].author; + pagesCell.textContent = myLibrary[i].pages; //add and wait for action for read/unread button let changeBut = document.createElement("button"); From d50b29035d22088a7935d7b1c22e6a8a192848e8 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 26 Nov 2026 16:04:54 +0000 Subject: [PATCH 12/15] Reset form fields after adding a new book to the library --- debugging/book-library/script.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index c5336be8e..7e3874aaf 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -42,6 +42,10 @@ function submit() { let book = new Book(title.value, author.value, pages.value, check.checked); myLibrary.push(book); render(); + title.value = ""; + author.value = ""; + pages.value = ""; + check.checked = false; } } From 4ce561a02f864b123edc13870c745b0af0273658 Mon Sep 17 00:00:00 2001 From: MattCarolus10 Date: Thu, 26 Nov 2026 16:13:07 +0000 Subject: [PATCH 13/15] Add title to the HTML document for better context --- debugging/book-library/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 23acfa71e..949a80d47 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -1,7 +1,7 @@ - + My Book Library Date: Thu, 26 Nov 2026 19:23:28 +0000 Subject: [PATCH 14/15] Fix input types for title and author fields in the book form --- 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 949a80d47..26fd4c5f2 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -31,7 +31,7 @@

Library

Library /> Date: Thu, 26 Nov 2026 19:25:32 +0000 Subject: [PATCH 15/15] Fix typo in book title in populateStorage function --- debugging/book-library/script.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 7e3874aaf..caeae2951 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -2,12 +2,11 @@ let myLibrary = []; window.addEventListener("load", function (e) { populateStorage(); - render(); }); function populateStorage() { if (myLibrary.length == 0) { - let book1 = new Book("Robison Crusoe", "Daniel Defoe", "252", true); + let book1 = new Book("Robinson Crusoe", "Daniel Defoe", "252", true); let book2 = new Book( "The Old Man and the Sea", "Ernest Hemingway",