File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,19 @@ const books = [
2323function readingList ( ) {
2424 const unorderedList = document . querySelector ( "#reading-list" ) ;
2525
26+ // Base condition: check if books array is empty
27+ if ( ! books || books . length === 0 ) {
28+ const emptyMessage = document . createElement ( "li" ) ;
29+ emptyMessage . textContent =
30+ "No books in your reading list yet. Add some books to get started!" ;
31+ emptyMessage . style . listStyle = "none" ;
32+ emptyMessage . style . padding = "20px" ;
33+ emptyMessage . style . textAlign = "center" ;
34+ emptyMessage . style . color = "#666" ;
35+ unorderedList . appendChild ( emptyMessage ) ;
36+ return ; // Exit the function early
37+ }
38+
2639 for ( const book of books ) {
2740 const newList = document . createElement ( "li" ) ;
2841
You can’t perform that action at this time.
0 commit comments