diff --git a/debugging/book-library/index.html b/debugging/book-library/index.html
index 23acfa71..2a4670f8 100644
--- a/debugging/book-library/index.html
+++ b/debugging/book-library/index.html
@@ -82,11 +82,11 @@
Library
+
diff --git a/debugging/book-library/readme.md b/debugging/book-library/readme.md
index 3abe8c13..8e50391d 100644
--- a/debugging/book-library/readme.md
+++ b/debugging/book-library/readme.md
@@ -13,11 +13,19 @@ My website should be able to:
## Bugs to be fixed
1. Website loads but doesn't show any books
+line 57 synthax error in render
2. Error in console when you try to add a book
+line 41 the original code tried pushing to a wrong array name
3. It uses the title name as the author name
+in line 40 title.value was repeated
4. Delete button is broken
+line 92 inconsistent name deleteBut
+line 97 typo
5. When I add a book that I say I've read - it saves the wrong answer
+line 80 no should be first
-I think there are other some other small bugs in my code...but I'm lazy so I can't fix them all.
-I wish somebody would help me!
+Other bugs:
+6. Changing status of Read changes status of all books
+redundant in HTML not isolating each row
+
diff --git a/debugging/book-library/script.js b/debugging/book-library/script.js
index 75ce6c1d..098c74ec 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,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
@@ -77,9 +77,9 @@ function render() {
wasReadCell.appendChild(changeBut);
let readStatus = "";
if (myLibrary[i].check == false) {
- readStatus = "Yes";
- } else {
readStatus = "No";
+ } else {
+ readStatus = "Yes";
}
changeBut.innerText = readStatus;
@@ -89,12 +89,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();
|