Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit ffb3575

Browse files
committed
exerciseThree
1 parent b0fd3bb commit ffb3575

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

Week-2/Homework/mandatory/2-exercises/exercises.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ function exerciseOne(arrayOfPeople) {
2929
targetElement.appendChild(newHeading); // add h1 to div with id='content'
3030
targetElement.appendChild(newSubHeading); // add h2 to div with id='content'
3131
});
32-
33-
3432
}
3533
/**
3634
*
@@ -50,15 +48,12 @@ function exerciseTwo(shopping) {
5048
// console.log(shoppingItem); // what does shopping item access?
5149
// create a list item for each item in the 'shopping' array
5250
let listItem = document.createElement('li');
53-
listItem.innerText = shoppingItem
51+
listItem.innerText = shoppingItem;
5452

5553
unorderedList.appendChild(listItem);
5654

5755
findElement.appendChild(unorderedList);
58-
})
59-
60-
61-
56+
});
6257
}
6358

6459
/**
@@ -92,6 +87,29 @@ function exerciseTwo(shopping) {
9287
**/
9388
function exerciseThree(books) {
9489
//Write your code in here
90+
const positionForParagraph = document.getElementById('content');
91+
// console.log(positionForParagraph);
92+
93+
let unorderedListForBooks = document.createElement('ul');
94+
positionForParagraph.appendChild(unorderedListForBooks);
95+
96+
books.forEach(book => {
97+
98+
let titleAndAuthor = document.createElement('p');
99+
// console.log(`${book.title} written by ${book.author}`);
100+
titleAndAuthor.innerText = `${book.title} written by ${book.author}`;
101+
102+
let listedItem = document.createElement('li');
103+
// console.log(listedItem);
104+
105+
let imageItem = document.createElement('img');
106+
console.log(imageItem);
107+
imageItem.style = background-color red
108+
109+
unorderedListForBooks.appendChild(listedItem);
110+
listedItem.appendChild(titleAndAuthor);
111+
listedItem.appendChild(imageItem);
112+
});
95113
}
96114

97115
//

0 commit comments

Comments
 (0)