Skip to content

Commit 7b319e7

Browse files
committed
bugfixing
1 parent 896cf58 commit 7b319e7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

debugging/book-library/script.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@ function submit() {
3131
if (
3232
title.value == null ||
3333
title.value == "" ||
34+
author.value == null ||
35+
author.value == "" ||
3436
pages.value == null ||
3537
pages.value == ""
3638
) {
3739
alert("Please fill all fields!");
3840
return false;
3941
} else {
40-
let book = new Book(title.value, title.value, pages.value, check.checked);
41-
library.push(book);
42+
let book = new Book(title.value, author.value, pages.value, check.checked);
43+
myLibrary.push(book);
4244
render();
4345
}
4446
}
@@ -77,9 +79,9 @@ function render() {
7779
wasReadCell.appendChild(changeBut);
7880
let readStatus = "";
7981
if (myLibrary[i].check == false) {
80-
readStatus = "Yes";
81-
} else {
8282
readStatus = "No";
83+
} else {
84+
readStatus = "Yes";
8385
}
8486
changeBut.innerText = readStatus;
8587

@@ -94,7 +96,7 @@ function render() {
9496
deleteCell.appendChild(delBut);
9597
delBut.className = "btn btn-warning";
9698
delBut.innerHTML = "Delete";
97-
delBut.addEventListener("clicks", function () {
99+
delBut.addEventListener("click", function () {
98100
alert(`You've deleted title: ${myLibrary[i].title}`);
99101
myLibrary.splice(i, 1);
100102
render();

0 commit comments

Comments
 (0)