Skip to content

Commit

Permalink
Fix: Move newBook variable into addBookToLibrary
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosfrontend committed Dec 19, 2023
1 parent 61ea87b commit 156dbed
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,10 @@ myLibrary.push(book7);
myLibrary.push(book8);
myLibrary.push(book9);

let newBook = new Book();

// Function that adds new books to myLibrary array from the user input
function addBookToLibrary() {
bookForm.addEventListener("submit", (e) => {
newBook = new Book(); // Create a blank instance of Book
const newBook = new Book(); // Create a blank instance of Book
// Get data of the form at submit
newBook.title = document.getElementById("title").value;
newBook.author = document.getElementById("author").value;
Expand Down

0 comments on commit 156dbed

Please sign in to comment.