MCPcopy Create free account
hub / github.com/Vishal-raj-1/Awesome-JavaScript-Projects / addBook

Function addBook

assets/js/libraryapp.js:14–24  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

12let myLibrary = [];
13//Adding a new Book
14const addBook = (e) => {
15 let title = document.getElementById("title");
16 let author = document.getElementById("author");
17 const isRead = document.getElementById("read-status").value;
18 if(title.value !== "" && author.value!== ""){
19 myLibrary.push(new Book(title.value,author.value,isRead));
20 displayBooks();
21 title.value = "";
22 author.value = "";
23 }
24}
25//Add button eventListener
26const addBookBtn = document.getElementById("add");
27addBookBtn.onclick = (e) => {

Callers 1

libraryapp.jsFile · 0.85

Calls 1

displayBooksFunction · 0.85

Tested by

no test coverage detected