Skip to content

ITP Jan 25 | Katarzyna Kazimierczuk | Data Flows | Library #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions debugging/book-library/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ <h1>Library</h1>
</thead>
<tbody>
<tr>
<!-- <td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td> -->
</tr>
</tbody>
</table>
Expand Down
12 changes: 10 additions & 2 deletions debugging/book-library/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <td> in HTML not isolating each row

14 changes: 7 additions & 7 deletions debugging/book-library/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand All @@ -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
Expand All @@ -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;

Expand All @@ -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();
Expand Down