@@ -93,16 +93,16 @@ makeBookList() */
93
93
}
94
94
}
95
95
96
- var fieldset = document . createElement ( 'fieldset' ) ;
97
- fieldset . setAttribute ( 'class' , 'nameOfList' ) ;
96
+ var fieldset = document . createElement ( 'fieldset' ) ; //creates a group
97
+ fieldset . setAttribute ( 'class' , 'nameOfList' ) ; //adds a class to the group
98
98
99
99
var legend = document . createElement ( 'legend' ) ;
100
100
legend . innerHTML = 'My Book List' ;
101
101
fieldset . appendChild ( legend ) ;
102
102
103
103
function makeBookList ( ) {
104
104
const ul = document . createElement ( 'ul' ) ; // creates the unord list
105
- const myBooks = Object . keys ( nameOfList )
105
+ const myBooks = Object . keys ( nameOfList ) //turns object into array (ie gives index)
106
106
107
107
108
108
const div = document . createElement ( 'div' ) ; //creates the div
@@ -111,26 +111,26 @@ function makeBookList(){
111
111
const h1third = document . createElement ( 'h1' ) ; // creates author h1
112
112
document . getElementsByTagName ( 'body' ) [ 0 ] . appendChild ( div ) ; //add the div to the body tag
113
113
div . appendChild ( ul ) ; //adds the ul to the div
114
- const img = document . createElement ( 'img' ) ;
114
+ const img = document . createElement ( 'img' ) ; // creates image
115
115
116
116
117
117
118
118
for ( let i = 0 ; i < myBooks . length ; i ++ ) {
119
- const li = document . createElement ( 'li' ) ;
120
- const li2 = document . createElement ( 'li' ) ;
121
- var bookImage = document . createElement ( 'img' ) ;
122
- const h2 = document . createElement ( 'h2' ) ;
123
- const h2second = document . createElement ( 'h2' ) ;
119
+ const li = document . createElement ( 'li' ) ; //creates list
120
+ const li2 = document . createElement ( 'li' ) ; //creates 2nd list
121
+ var bookImage = document . createElement ( 'img' ) ; //creates img
122
+ const h2 = document . createElement ( 'h2' ) ; //creates h2
123
+ const h2second = document . createElement ( 'h2' ) ; //creates 2nd h2
124
124
const h1 = document . createElement ( 'h1' ) ; // creates title h1
125
- var bookId = myBooks [ i ] ;
125
+ var bookId = myBooks [ i ] ; //creates index of index
126
126
127
127
const myBook = nameOfList [ bookId ] ;
128
- h1 . innerHTML = myBook . title ;
129
- h2 . innerHTML = ( "author" ) ;
130
- li . innerHTML = myBook . language ;
131
- h2second . innerHTML = ( "language" ) ;
132
- li2 . innerHTML = myBook . author ;
133
- ul . appendChild ( h1second ) ;
128
+ h1 . innerHTML = myBook . title ; //writes h1 to html
129
+ h2 . innerHTML = ( "author" ) ; //writes h2 to html author
130
+ li . innerHTML = myBook . language ; //writes property of language to li
131
+ h2second . innerHTML = ( "language" ) ; //writes 2nd h2 to html
132
+ li2 . innerHTML = myBook . author ; //writes property of author to li2
133
+ ul . appendChild ( h1second ) ; //below all added to ul
134
134
135
135
ul . appendChild ( h1 ) ;
136
136
ul . appendChild ( h1third ) ;
@@ -143,12 +143,12 @@ function makeBookList(){
143
143
144
144
145
145
146
- var bookImage = document . createElement ( 'img' ) ; //Create a img for the book in the div and give it an attribute
147
- bookImage . src = 'img/' + bookTitles [ i ] + '.jpg' ;
148
- bookImage . setAttribute ( 'alt' , bookTitles [ i ] ) ;
149
- bookImage . setAttribute ( 'height' , '300px' ) ;
150
- bookImage . setAttribute ( 'width' , '200px' ) ;
151
- ul . append ( bookImage ) ;
146
+ var bookImage = document . createElement ( 'img' ) ; // creates image
147
+ bookImage . src = 'img/' + bookTitles [ i ] + '.jpg' ; //adds src of book titles array
148
+ bookImage . setAttribute ( 'alt' , bookTitles [ i ] ) ; // adds alt to image
149
+ bookImage . setAttribute ( 'height' , '300px' ) ; //adds height
150
+ bookImage . setAttribute ( 'width' , '200px' ) ; // adds width
151
+ ul . append ( bookImage ) ; //adds to ul
152
152
153
153
}
154
154
fieldset . appendChild ( div ) ;
0 commit comments