This repository was archived by the owner on Dec 18, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 44 < meta charset ="utf-8 " />
55 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
66 < link rel ="stylesheet " href ="style.css " />
7- < title > Title here </ title >
7+ < title > Reading list app </ title >
88 </ head >
99 < body >
1010 < div id ="content ">
Original file line number Diff line number Diff line change @@ -21,3 +21,30 @@ const books = [
2121 } ,
2222] ;
2323
24+ const container = document . getElementById ( "reading-list" ) ;
25+
26+ function appendBook ( book ) {
27+ const liBook = document . createElement ( "li" ) ;
28+
29+ const description = document . createElement ( "p" ) ;
30+ description . textContent = book . title + " by " + book . author ;
31+
32+ const alreadyRead = book . alreadyRead ;
33+ const imgSrc = document . createElement ( "img" ) ;
34+ imgSrc . setAttribute ( "src" , book . bookCoverImage ) ;
35+ imgSrc . style . height = "400px" ;
36+ if ( alreadyRead ) {
37+ liBook . style . backgroundColor = "green" ;
38+ } else {
39+ liBook . style . backgroundColor = "red" ;
40+ }
41+ liBook . appendChild ( description ) ;
42+
43+ liBook . appendChild ( imgSrc ) ;
44+
45+ container . appendChild ( liBook ) ;
46+ }
47+
48+ for ( let book of books ) {
49+ appendBook ( book ) ;
50+ }
You can’t perform that action at this time.
0 commit comments