Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sprint-3/reading-list/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Title here</title>
<title>Reading list app</title>
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

</head>
<body>
<div id="content">
Expand Down
33 changes: 33 additions & 0 deletions Sprint-3/reading-list/script.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
document.addEventListener("DOMContentLoaded", () => {
//elements of page to interact with
for (let book of books){
const title = book.title;
const author = book.author;
const alreadyRead = book.alreadyRead;
const bookCoverImage = book.bookCoverImage;
Comment on lines +4 to +7
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job with this.
Just a few minor improvements you could make:

  1. Seeing as the value of book won't change inside our for loop, do you think there is a better way to initialize it.
  2. While this will work fine, can you find out if there is a cleaner way to unpack object properties into variables.

const readingListDom = document.getElementById("reading-list")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to initialize the readingListDom object inside this block. Could you look into why that would be problematic?


let bookDiv = document.createElement("div");
bookDiv.classList.add("book");
if (alreadyRead == true){
bookDiv.classList.add("alreadyRead");
}
let titleDom = document.createElement("p");
titleDom.innerText = title;
let authorDom = document.createElement("p");
authorDom.innerText = author;
let imageDom = document.createElement("img");
imageDom.src = bookCoverImage;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Although img tags typically include a certain attribute that you haven't added here. The attribute is meant to improve accessibility and it is also displayed in place of the image in case it does not load. Please look into it.



bookDiv.appendChild(titleDom);
bookDiv.appendChild(authorDom);
bookDiv.appendChild(imageDom);

readingListDom.appendChild(bookDiv);
}

});



// for the tests, do not modify this array of books
const books = [
{
Expand Down
6 changes: 6 additions & 0 deletions Sprint-3/reading-list/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,9 @@ body {
max-height: 80px;
}
}
.book{
background-color: red;
}
.alreadyRead{
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this will work fine, css classes are typically not written in camelCase.

background-color: green;
}
Loading