Skip to content

Commit ccda39b

Browse files
committed
Fix add book functionality
1 parent 2b6d970 commit ccda39b

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

debugging/book-library/script.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,26 @@ function populateStorage() {
2020
}
2121
}
2222

23-
const title = document.getElementById("title");
24-
const author = document.getElementById("author");
25-
const pages = document.getElementById("pages");
26-
const check = document.getElementById("check");
27-
2823
//check the right input from forms and if its ok -> add the new book (object in array)
2924
//via Book function and start render function
3025
function submit() {
26+
const title = document.getElementById("title");
27+
const author = document.getElementById("author");
28+
const pages = document.getElementById("pages");
29+
const check = document.getElementById("check");
3130
if (
3231
title.value == null ||
3332
title.value == "" ||
33+
author.value == null ||
34+
author.value == "" ||
3435
pages.value == null ||
3536
pages.value == ""
3637
) {
3738
alert("Please fill all fields!");
3839
return false;
3940
} else {
4041
let book = new Book(title.value, author.value, pages.value, check.checked);
41-
Mylibrary.push(book);
42+
myLibrary.push(book);
4243
render();
4344
}
4445
}
@@ -76,7 +77,7 @@ function render() {
7677
changeBut.className = "btn btn-success";
7778
wasReadCell.appendChild(changeBut);
7879
let readStatus = "";
79-
if (myLibrary[i].check == false) {
80+
if (myLibrary[i].check == true) {
8081
readStatus = "Yes";
8182
} else {
8283
readStatus = "No";

0 commit comments

Comments
 (0)