Skip to content

Commit b8b977b

Browse files
committed
fixed the bugs
1 parent b6e236f commit b8b977b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

debugging/book-library/script.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
let myLibrary = [];
22

33
window.addEventListener("load", function (e) {
4-
populateStorage();
4+
if (localStorage.getItem("myLibrary")) {
5+
myLibrary = JSON.parse(localStorage.getItem("myLibrary"));
6+
} else {
7+
populateStorage();
8+
}
59
render();
610
});
7-
811
function populateStorage() {
912
if (myLibrary.length == 0) {
1013
let book1 = new Book("Robinson Crusoe", "Daniel Defoe", "252", true);

0 commit comments

Comments
 (0)