Skip to content

Commit 312865b

Browse files
committed
Fix book submission logic by correcting author assignment and clearing input fields
1 parent 504b1d2 commit 312865b

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎debugging/book-library/script.js‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,18 @@ function submit() {
3131
alert("Please fill all fields!");
3232
return false;
3333
} else {
34-
let book = new Book(title.value, title.value, pages.value, check.checked);
35-
library.push(book);
34+
let book = new Book(title.value, author.value, pages.value, check.checked);
35+
myLibrary.push(book);
36+
37+
// Add these lines to clear the text boxes after adding:
38+
title.value = "";
39+
author.value = "";
40+
pages.value = "";
41+
check.checked = false;
42+
3643
render();
3744
}
3845
}
39-
4046
function Book(title, author, pages, check) {
4147
this.title = title;
4248
this.author = author;

0 commit comments

Comments
 (0)