From d011e814693fb522f8bc99200fe2ee462b6f110d Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 25 Nov 2026 22:43:14 +0000 Subject: [PATCH 01/14] Fix syntax error in render function loop --- 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 1e31fd1d8c66bab6b0ebe0a8515ce09c5602b4fe Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 25 Nov 2026 22:46:10 +0000 Subject: [PATCH 02/14] Fix reference 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 eed706fdc..51a8c1cb6 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 40dfdc04e8817e066fc174d61a03360bfc4d5094 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 25 Nov 2026 22:48:36 +0000 Subject: [PATCH 03/14] Fix author reference in book submission --- 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 51a8c1cb6..45277227e 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 3b6ff4664dbc245181b69beeb846e2fe2675833a Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 25 Nov 2026 22:53:43 +0000 Subject: [PATCH 04/14] Fix variable name for delete button in render 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 45277227e..19b79b96e 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -89,8 +89,7 @@ function render() { }); //add delete button to every row and render again - let delButton = document.createElement("button"); - delBut.id = i + 5; + let delBut = document.createElement("button"); deleteCell.appendChild(delBut); delBut.className = "btn btn-warning"; delBut.innerHTML = "Delete"; From fe52491e88f05614ba30ed76a1a121269e36c2f4 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 25 Nov 2026 22:58:29 +0000 Subject: [PATCH 05/14] Fix read status condition 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 19b79b96e..4ce6bd1db 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -76,7 +76,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 cb6f8859e7e289589f1fe2c2a207cfa847d84fb6 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 25 Nov 2026 23:00:05 +0000 Subject: [PATCH 06/14] Fix validation check for author field 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 4ce6bd1db..7d81e518d 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -30,7 +30,7 @@ const check = document.getElementById("check"); function submit() { if ( title.value == null || - title.value == "" || + author.value == "" || pages.value == null || pages.value == "" ) { From 170437cebc7ba6e2a22e023d1d5868cb87134355 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 25 Nov 2026 23:01:05 +0000 Subject: [PATCH 07/14] Simplify validation check in submit function --- debugging/book-library/script.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js index 7d81e518d..308fc89cb 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -28,12 +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 == null || - author.value == "" || - pages.value == null || - pages.value == "" - ) { + if (title.value == "" || author.value == "" || pages.value == "") { alert("Please fill all fields!"); return false; } else { From 4d5e044b6161e83371ece2a2fce65a5c8a48df9b Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 25 Nov 2026 23:04:13 +0000 Subject: [PATCH 08/14] Fix row insertion position 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 308fc89cb..430e4c5b4 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -55,7 +55,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); From 9a98566970fabe688640aaa1d9e4436eba79d956 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 25 Nov 2026 23:07:17 +0000 Subject: [PATCH 09/14] Reset form fields after adding a new book --- 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 430e4c5b4..d2e01b801 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -35,6 +35,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 632b8e6a03dfe18adfb31ca6a2fd5436f6374541 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 25 Nov 2026 23:09:21 +0000 Subject: [PATCH 10/14] Fix label input types for author and title --- debugging/book-library/index.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html index 23acfa71e..a8db7c309 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -1,4 +1,4 @@ - + @@ -31,7 +31,7 @@

Library

Library /> Library type="submit" value="Submit" class="btn btn-primary" - onclick="submit();" + onclick="submit()" />
From 1d4095f7af0c57991f0f1fc2f7e93752ee831349 Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 25 Nov 2026 23:12:25 +0000 Subject: [PATCH 11/14] Set the title for the Book Library page --- 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 a8db7c309..d7a143f17 100644 --- a/debugging/book-library/index.html +++ b/debugging/book-library/index.html @@ -1,7 +1,7 @@ - + Book Library Date: Wed, 25 Nov 2026 23:15:28 +0000 Subject: [PATCH 12/14] Remove redundant render call on window load --- 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 d2e01b801..19f623b44 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -2,7 +2,6 @@ let myLibrary = []; window.addEventListener("load", function (e) { populateStorage(); - render(); }); function populateStorage() { From 5e9a93f383c715cf056b7fd2a2204c5793b6766b Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 25 Nov 2026 23:18:44 +0000 Subject: [PATCH 13/14] 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 19f623b44..8eca52f41 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -91,7 +91,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 961177cc76a925de9aa422e8b08ad99d667976ca Mon Sep 17 00:00:00 2001 From: Precious Moses Date: Wed, 25 Nov 2026 23:19:34 +0000 Subject: [PATCH 14/14] Fix typo in book title for initial library population --- 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 8eca52f41..dacfd869a 100644 --- a/debugging/book-library/script.js +++ b/debugging/book-library/script.js @@ -6,7 +6,7 @@ window.addEventListener("load", function (e) { 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",