Skip to content

Commit 8b302b9

Browse files
committed
feat: adds input field resets and descriptive deletion notifications
1 parent c968435 commit 8b302b9

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

debugging/book-library/script.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ function addBook(e) {
4242
myLibrary.push(book);
4343
saveStorage();
4444
render();
45+
46+
// Resets the entry form after adding a book
47+
titleInput.value = "";
48+
authorInput.value = "";
49+
pagesInput.value = "";
50+
readCheckbox.checked = false;
4551
}
4652

4753
function Book(title, author, pages, check) {
@@ -84,16 +90,18 @@ function render() {
8490
render();
8591
});
8692

87-
// Deletes the book from the library
93+
// Deletes the book and notifies the user
8894
const deleteBtn = document.createElement("button");
8995
deleteBtn.className = "btn btn-danger btn-sm";
9096
deleteBtn.textContent = "Delete";
9197
deleteCell.appendChild(deleteBtn);
9298

9399
deleteBtn.addEventListener("click", () => {
100+
const deletedTitle = book.title;
94101
myLibrary.splice(i, 1);
95102
saveStorage();
96103
render();
104+
alert(`Success: "${deletedTitle}" has been removed.`);
97105
});
98106
});
99107
}

0 commit comments

Comments
 (0)