forked from HackYourFuture/JavaScript2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex1-bookList.js
More file actions
42 lines (33 loc) · 1.06 KB
/
ex1-bookList.js
File metadata and controls
42 lines (33 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
** Exercise 1: The book list **
I 'd like to display my three favorite books inside a nice webpage!
1. Iterate through the array of books.
2. For each book, create a `<p>`
element with the book title and author and append it to the page.
3. Use a `<ul>` and `<li>` to display the books.
4. Add an `<img>` to each book that links to a URL of the book cover.
5. Change the style of the book depending on whether you have read it(green) or not(red).
The end result should look something like this:
https: //hyf-js2-week1-makeme-ex1-demo.herokuapp.com/
*/
function createBookList(books) {
// your code goes in here, return the ul element
}
const books = [{
title: 'The Design of Everyday Things',
author: 'Don Norman',
alreadyRead: false
},
{
title: 'The Most Human Human',
author: 'Brian Christian',
alreadyRead: true
},
{
title: 'The Pragmatic Programmer',
author: 'Andrew Hunt',
alreadyRead: true
}
];
let ulElement = createBookList(books);
document.querySelector("#bookList").appendChild(ulElement);