Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.
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
137 changes: 132 additions & 5 deletions Week1/homework/app.js
Original file line number Diff line number Diff line change
@@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks good!

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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Although this solution to add the images works it is not what was asked for in the instructions. Please read 1.7 and 1.8 again. And implement it like it is written there.

Copy link
Author

Choose a reason for hiding this comment

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

done

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);
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Week1/homework/images/Beloved.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Week1/homework/images/Chernobyl_Prayer.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Week1/homework/images/Runaway.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Week1/homework/images/The_Goldfinch.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion Week1/homework/index.html
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
<!-- replace this with your HTML content -->
<!DOCTYPE html>
<html>

<head>
<link rel="stylesheet" href="style.css">
<title>Title</title>
</head>

<body>
<h1>Title</h1>
<script src="app.js"></script>
</body>

</html>
42 changes: 41 additions & 1 deletion Week1/homework/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,41 @@
/* add your styling here */
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;
}
21 changes: 14 additions & 7 deletions Week2/homework/maartjes-work.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions Week2/homework/map-filter.js
Original file line number Diff line number Diff line change
@@ -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];
Expand Down