Skip to content

Commit a1af7d4

Browse files
committed
create loop through book object to render book list, title, author and image
1 parent b52d229 commit a1af7d4

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Sprint-3/reading-list/script.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ const books = [
2222
bookCoverImage: "https://blackwells.co.uk/jacket/l/9780135957059.jpg",
2323
},
2424
];
25-
function readingList(arrays){
25+
function readingList(bookArray){
2626
const contentEl = document.getElementById("content");
2727
const ulListEl = document.getElementById("reading-list");
28+
29+
for (const book of bookArray){
2830
const li = document.createElement("li");
2931
ulListEl.appendChild(li);
30-
li.textContent ="placeholder text";
32+
li.textContent = `${book.title} by ${book.author}`;
3133
const img = document.createElement('img');
3234
li.appendChild(img)
33-
img.src = "https://blackwells.co.uk/jacket/l/9780135957059.jpg";
34-
35+
img.src = book.bookCoverImage;
36+
}
3537
}
3638
readingList(books);
3739
// Render the list of books on the page. Each book should have a title, author and image and a background colour that is set dependent on whether we have read the book or not.

0 commit comments

Comments
 (0)