Skip to content

Commit 7a0867a

Browse files
committed
update
1 parent d204bf0 commit 7a0867a

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

Week1/homework/app.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,16 @@ makeBookList() */
9393
}
9494
}
9595

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
9898

9999
var legend = document.createElement( 'legend' );
100100
legend.innerHTML = 'My Book List';
101101
fieldset.appendChild(legend);
102102

103103
function makeBookList(){
104104
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)
106106

107107

108108
const div = document.createElement('div'); //creates the div
@@ -111,26 +111,26 @@ function makeBookList(){
111111
const h1third = document.createElement('h1'); // creates author h1
112112
document.getElementsByTagName('body')[0].appendChild(div); //add the div to the body tag
113113
div.appendChild(ul); //adds the ul to the div
114-
const img = document.createElement('img');
114+
const img = document.createElement('img'); // creates image
115115

116116

117117

118118
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
124124
const h1 = document.createElement('h1'); // creates title h1
125-
var bookId = myBooks[i];
125+
var bookId = myBooks[i]; //creates index of index
126126

127127
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
134134

135135
ul.appendChild(h1);
136136
ul.appendChild(h1third);
@@ -143,12 +143,12 @@ function makeBookList(){
143143

144144

145145

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
152152

153153
}
154154
fieldset.appendChild(div);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy