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 + + + + + + Title + + + +

Title

+ + + + \ No newline at end of file diff --git a/Week1/homework/style.css b/Week1/homework/style.css index bab13ec23..d6b84d244 100644 --- a/Week1/homework/style.css +++ b/Week1/homework/style.css @@ -1 +1,41 @@ -/* add your styling here */ \ No newline at end of file +body { + text-align: center; + line-height: .65rem; +} + +ul { + list-style:none; + display: flex; + flex-flow: row wrap; + justify-content: space-around; + align-items: baseline; +} + +img { + max-height: 400px; + max-width: calc(270px - 2 * 10px - 5px); + box-shadow: 10px 10px 5px grey; +} + +li { + width: 270px; + overflow: hidden; + margin: 30px 45px; +} + +h3 { + font-size: 1.65rem; + line-height: 1.65rem; + margin: 45px 0; +} + +p { + text-align: left; + font-size: 1.05rem; + font-style: italic; +} + +.author { + font-size: 1.2rem; + font-weight: bold; +} \ No newline at end of file diff --git a/Week2/homework/maartjes-work.js b/Week2/homework/maartjes-work.js index 49772eb44..ea14cf37f 100644 --- a/Week2/homework/maartjes-work.js +++ b/Week2/homework/maartjes-work.js @@ -46,16 +46,23 @@ const maartjesTasks = monday.concat(tuesday); const maartjesHourlyRate = 20; function computeEarnings(tasks, hourlyRate) { - // Replace this comment and the next line with your code - console.log(tasks, hourlyRate); -} + const durations = []; + for (const obj of tasks) { + durations.push(obj.duration); + } + + const hourlyDurations = durations.map(minutes => minutes / 60); + + const consideringDurations = hourlyDurations.filter(hours => hours >= 2); -// eslint-disable-next-line no-unused-vars -const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate); + const earnings = consideringDurations.reduce((amount, hours) => amount + hours * hourlyRate, 0); + + return earnings; +} -// add code to convert `earnings` to a string rounded to two decimals (euro cents) +const maartjesEarnings = computeEarnings(maartjesTasks, maartjesHourlyRate).toFixed(2); -console.log(`Maartje has earned €${'replace this string with the earnings rounded to euro cents'}`); +console.log(`Maartje has earned €${maartjesEarnings}`); // Do not change or remove anything below this line module.exports = { diff --git a/Week2/homework/map-filter.js b/Week2/homework/map-filter.js index c8e8a88c1..8df2b01d3 100644 --- a/Week2/homework/map-filter.js +++ b/Week2/homework/map-filter.js @@ -1,8 +1,8 @@ 'use strict'; function doubleOddNumbers(numbers) { - // Replace this comment and the next line with your code - console.log(numbers); + const newNumbers = numbers.filter(i => i % 2 !== 0).map(i => i * 2); + return newNumbers; } const myNumbers = [1, 2, 3, 4];