Skip to content

Commit 43b06b0

Browse files
committed
fix: correct book object creation in submit function
1 parent 556cd3e commit 43b06b0

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

debugging/book-library/script.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,12 @@ const check = document.getElementById("check");
2828
//check the right input from forms and if its ok -> add the new book (object in array)
2929
//via Book function and start render function
3030
function submit() {
31-
if (
32-
title.value == null ||
33-
title.value == "" ||
34-
pages.value == null ||
35-
pages.value == ""
36-
) {
31+
if (!title.value || !author.value || pages.value <= 0) {
3732
alert("Please fill all fields!");
3833
return false;
3934
} else {
40-
let book = new Book(title.value, title.value, pages.value, check.checked);
41-
library.push(book);
35+
let book = new Book(title.value, author.value, pages.value, check.checked);
36+
myLibrary.push(book);
4237
render();
4338
}
4439
}

0 commit comments

Comments
 (0)