diff --git a/Week1/homework/app.js b/Week1/homework/app.js index a9b5f75d8..6d07b0788 100644 --- a/Week1/homework/app.js +++ b/Week1/homework/app.js @@ -1,11 +1,138 @@ 'use strict'; { - const bookTitles = [ - // Replace with your own book titles - 'harry_potter_chamber_secrets', + const booksArray = [ + `The_Goldfinch`, + `A_Garden_of_Earthly_Delights`, + `Beloved`, + `There_Once_Lived_a_Woman_Who_Tried_to_Kill_Her_Neighbors_Baby`, + `The_House_of_the_Spirits`, + `The_Left_Hand_of_Darkness`, + `The_Unwomanly_Face_of_War`, + `Chernobyl_Prayer`, + `Runaway`, + `The_Year_of_Magical_Thinking`, ]; - // Replace with your own code - console.log(bookTitles); + const booksObject = { + The_Goldfinch: { + title: `The Goldfinch`, + author: `Donna Tartt`, + original_language: `English`, + }, + A_Garden_of_Earthly_Delights: { + title: `A Garden of Earthly Delights`, + author: `Carol Oates`, + original_language: `English`, + }, + Beloved: { + title: `Beloved`, + author: `Toni Morrison`, + original_language: `English`, + }, + There_Once_Lived_a_Woman_Who_Tried_to_Kill_Her_Neighbors_Baby: { + title: `There Once Lived a Woman Who Tried to Kill Her Neighbo\'s Baby`, + author: `Lyudmila Petrushevskaya`, + original_language: `Russian`, + }, + The_House_of_the_Spirits: { + title: `The House of the Spirits`, + author: `Isabel Allende`, + original_language: `Spanish`, + }, + The_Left_Hand_of_Darkness: { + title: `The Left Hand of Darkness`, + author: `Ursula K. Le Guin`, + original_language: `English`, + }, + The_Unwomanly_Face_of_War: { + title: `The Unwomanly Face of War`, + author: `Svetlana Alexievich`, + original_language: `Russian`, + }, + Chernobyl_Prayer: { + title: `Chernobyl Prayer`, + author: `Svetlana Alexievich`, + original_language: `Russian`, + }, + Runaway: { + title: `Runaway`, + author: `Alice Munro`, + original_language: `English`, + }, + The_Year_of_Magical_Thinking: { + title: `The Year of Magical Thinking`, + author: `Joan Didion`, + original_language: `English`, + }, + }; + + const booksList = document.createElement(`ul`); + document.body.insertBefore(booksList, document.body.childNodes[2]); + + for (const book of booksArray) { + const listItem = document.createElement(`li`); + booksList.appendChild(listItem); + listItem.setAttribute(`id`, book); + + const title = document.createElement(`h3`); + listItem.appendChild(title); + const titleContent = document.createTextNode(booksObject[book].title); + title.appendChild(titleContent); + + const author = document.createElement(`p`); + listItem.appendChild(author); + author.setAttribute(`class`, `author`); + const authorContent = document.createTextNode(`By ${booksObject[book].author}`); + author.appendChild(authorContent); + + const original_language = document.createElement(`p`); + listItem.appendChild(original_language); + const original_languageContent = document.createTextNode( + `Original language: ${booksObject[book].original_language}`, + ); + original_language.appendChild(original_languageContent); + } + + const imagesObject = { + The_Goldfinch: { + url: `images/The_Goldfinch.jpg`, + }, + A_Garden_of_Earthly_Delights: { + url: `images/A_Garden_of_Earthly_Delights.jpg`, + }, + Beloved: { + url: `images/Beloved.jpg`, + }, + There_Once_Lived_a_Woman_Who_Tried_to_Kill_Her_Neighbors_Baby: { + url: `images/There_Once_Lived_a_Woman_Who_Tried_to_Kill_Her_Neighbors_Baby.jpg`, + }, + The_House_of_the_Spirits: { + url: `images/The_House_of_the_Spirits.jpg`, + }, + The_Left_Hand_of_Darkness: { + url: `images/The_Left_Hand_of_Darkness.jpg`, + }, + The_Unwomanly_Face_of_War: { + url: `images/The_Unwomanly_Face_of_War.jpg`, + }, + Chernobyl_Prayer: { + url: `images/Chernobyl_Prayer.jpg`, + }, + Runaway: { + url: `images/Runaway.jpg`, + }, + The_Year_of_Magical_Thinking: { + url: `images/The_Year_of_Magical_Thinking.jpg`, + }, + }; + + for (const book of booksArray) { + const listItem = document.getElementById(book); + + const image = document.createElement(`img`); + listItem.appendChild(image); + listItem.insertBefore(image, listItem.childNodes[0]); + image.setAttribute(`src`, imagesObject[book].url); + } } diff --git a/Week1/homework/images/A_Garden_of_Earthly_Delights.jpg b/Week1/homework/images/A_Garden_of_Earthly_Delights.jpg new file mode 100644 index 000000000..34e7ff029 Binary files /dev/null and b/Week1/homework/images/A_Garden_of_Earthly_Delights.jpg differ diff --git a/Week1/homework/images/Beloved.jpg b/Week1/homework/images/Beloved.jpg new file mode 100644 index 000000000..0d7903088 Binary files /dev/null and b/Week1/homework/images/Beloved.jpg differ diff --git a/Week1/homework/images/Chernobyl_Prayer.jpg b/Week1/homework/images/Chernobyl_Prayer.jpg new file mode 100644 index 000000000..457a648f9 Binary files /dev/null and b/Week1/homework/images/Chernobyl_Prayer.jpg differ diff --git a/Week1/homework/images/Runaway.jpg b/Week1/homework/images/Runaway.jpg new file mode 100644 index 000000000..3140dda9b Binary files /dev/null and b/Week1/homework/images/Runaway.jpg differ diff --git a/Week1/homework/images/The_Goldfinch.jpg b/Week1/homework/images/The_Goldfinch.jpg new file mode 100644 index 000000000..297045b09 Binary files /dev/null and b/Week1/homework/images/The_Goldfinch.jpg differ diff --git a/Week1/homework/images/The_House_of_the_Spirits.jpg b/Week1/homework/images/The_House_of_the_Spirits.jpg new file mode 100644 index 000000000..5c16cd196 Binary files /dev/null and b/Week1/homework/images/The_House_of_the_Spirits.jpg differ diff --git a/Week1/homework/images/The_Left_Hand_of_Darkness.jpg b/Week1/homework/images/The_Left_Hand_of_Darkness.jpg new file mode 100644 index 000000000..5237e99d2 Binary files /dev/null and b/Week1/homework/images/The_Left_Hand_of_Darkness.jpg differ diff --git a/Week1/homework/images/The_Unwomanly_Face_of_War.jpg b/Week1/homework/images/The_Unwomanly_Face_of_War.jpg new file mode 100644 index 000000000..6e17820cb Binary files /dev/null and b/Week1/homework/images/The_Unwomanly_Face_of_War.jpg differ diff --git a/Week1/homework/images/The_Year_of_Magical_Thinking.jpg b/Week1/homework/images/The_Year_of_Magical_Thinking.jpg new file mode 100644 index 000000000..eaf077273 Binary files /dev/null and b/Week1/homework/images/The_Year_of_Magical_Thinking.jpg differ diff --git a/Week1/homework/images/There_Once_Lived_a_Woman_Who_Tried_to_Kill_Her_Neighbors_Baby.jpg b/Week1/homework/images/There_Once_Lived_a_Woman_Who_Tried_to_Kill_Her_Neighbors_Baby.jpg new file mode 100644 index 000000000..0fd581076 Binary files /dev/null and b/Week1/homework/images/There_Once_Lived_a_Woman_Who_Tried_to_Kill_Her_Neighbors_Baby.jpg differ diff --git a/Week1/homework/index.html b/Week1/homework/index.html index b22147cd1..3c395bad4 100644 --- a/Week1/homework/index.html +++ b/Week1/homework/index.html @@ -1 +1,14 @@ - \ No newline at end of file + + + +
+ +