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
135 changes: 131 additions & 4 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'
'a_game_of_thrones',
'a_clash_of_kings',
'a_storm_of_swords',
'a_feast_of_crows',
'a_dance_with_dragons',
'harry_potter_chamber_secrets',
'harry_potter_prisoner_azkaban',
'harry_potter_goblet_fire',
'harry_potter_order_phoenix',
'harry_potter_deathly_hallows'
];

const booksInfo = {
a_game_of_thrones: {
title: 'A Song of Ice and Fire - A Game of Thrones',
language: 'English',
author: 'George R.R. Martin',
pages: '694',
},

// Replace with your own code
console.log(bookTitles);
a_clash_of_kings: {
title: 'A Song of Ice and Fire - A Clash of Kings',
language: 'English',
author: 'George R.R. Martin',
pages: '768',
},
a_storm_of_swords: {
title: 'A Song of Ice and Fire - A Storm of Swords',
language: 'English',
author: 'George R.R. Martin',
pages: '973',
},
a_feast_of_crows: {
title: 'A Song of Ice and Fire - A Feast of crows',
language: 'English',
author: 'George R.R. Martin',
pages: '753',
},
a_dance_with_dragons: {
title: 'A Song of Ice and Fire - A Dance with Dragons',
language: 'English',
author: 'George R.R. Martin',
pages: '1040',
},
harry_potter_chamber_secrets: {
title: 'Harry Potter and the Chamber of Secrets',
language: 'English',
author: 'J. K. Rowling',
pages: '251',
},
harry_potter_prisoner_azkaban: {
title: 'Harry Potter and the Prisoner of Azkaban',
language: 'English',
author: 'J. K. Rowling',
pages: '317',
},
harry_potter_goblet_fire: {
title: 'Harry Potter and the Goblet of Fire',
language: 'English',
author: 'J. K. Rowling',
pages: '636',
},
harry_potter_order_phoenix: {
title: 'Harry Potter and the Order of the Phoenix',
language: 'English',
author: 'J. K. Rowling',
pages: '766',
},
harry_potter_deathly_hallows: {
title: 'Harry Potter and the Deathly Hallows',
language: 'English',
author: 'J. K. Rowling',
pages: '694',
}
};

function main() {
const container = document.getElementById('myBooks');
const Header = document.createElement('h1');
Header.innerHTML = 'My Top 10 Books';
container.appendChild(Header);

const booksList = document.createElement('ul');
container.appendChild(booksList);

for (const i in booksInfo) {
const li = document.createElement('li');
booksList.appendChild(li);
li.setAttribute("id", [i]);

const title = document.createElement('h2');
li.appendChild(title);
title.innerHTML = booksInfo[i].title;

const language = document.createElement('p');
li.appendChild(language);
language.innerHTML = 'Language: ' + booksInfo[i].language;

const author = document.createElement('p');
li.appendChild(author);
author.innerHTML = 'Author: ' + booksInfo[i].author;

const pages = document.createElement('p');
li.appendChild(pages);
pages.innerHTML = 'Pages: ' + booksInfo[i].pages;
}


const images = {
a_game_of_thrones: './img/a_game_of_Thrones.jpg',
a_clash_of_kings: './img/a_clash_of_kings.jpg',
a_storm_of_swords: './img/a_storm_of_swords.jpg',
a_feast_of_crows: './img/a_feast_of_crows.jpg',
a_dance_with_dragons: './img/a_dance_with_dragons.jpg',
harry_potter_chamber_secrets: './img/harry_potter_chamber_secrets.jpeg',
harry_potter_prisoner_azkaban: './img/harry_potter_prisoner_azkaban.jpg',
harry_potter_goblet_fire: './img/harry_potter_goblet_fire.jpg',
harry_potter_order_phoenix: './img/harry_potter_order_phoenix.jpeg',
harry_potter_deathly_hallows: './img/harry_potter_deathly_hallows.jpg'
};

for (const key in images) {
const img = document.createElement('img');
img.setAttribute('src', images[key]);
img.setAttribute('alt', key);

const imgList = document.createElement('li');
imgList.appendChild(img);

const x = document.getElementById(key);
x.appendChild(imgList);
}
}
window.addEventListener('load', main);
}
Binary file added Week1/homework/img/a_clash_of_kings.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/img/a_dance_with_dragons.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/img/a_feast_of_crows.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/img/a_game_of_thrones.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/img/a_storm_of_swords.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.
Binary file added Week1/homework/img/harry_potter_goblet_fire.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.
16 changes: 15 additions & 1 deletion Week1/homework/index.html
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
<!-- replace this with your HTML content -->
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" media="screen" href="style.css" />
<title></title>
</head>

<body>
<div id="myBooks"></div>
<script type="text/javascript" src="app.js"></script>
</body>

</html>
17 changes: 16 additions & 1 deletion Week1/homework/style.css
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
/* add your styling here */
*{
list-style-type: none;
}

img{
width: 200px;
border: 2px solid black
}

h1, h2, p{
font-family: "tahoma";
}

#myBooks {
text-align: center;
}
7 changes: 7 additions & 0 deletions Week2/homework/maartjes_work.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@ const tuesday = [
const tasks = monday.concat(tuesday);

// Add your code here
const salary = tasks
Copy link

Choose a reason for hiding this comment

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

you could consider making the function more descriptive e.g. calculateSalary

.map((task) => (task.duration / 60))
.filter((duration) => duration >= 2)
.map((duration) => duration * 23)
.reduce((acc, current) => acc + current);

console.log('Maartje has earned €' + salary.toFixed(2));
Copy link

@silksil silksil Jun 3, 2018

Choose a reason for hiding this comment

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

I personaly would move the .toFixed(2) to the function 'salary'

Copy link

Choose a reason for hiding this comment

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

you could consider to pass the tasks and salary as two arguments, something like:

const calculateEarnings = (arrayOfTasks, hourlyWage) =>
arrayOfTasks.map((task) => task.duration / 60)
.filter((hoursAmount) => hoursAmount >= 2)
.map((paidHoursAmount) => paidHoursAmount * hourlyWage)
.reduce((sum, amount) => sum + amount, 0)
.toFixed(2);

5 changes: 5 additions & 0 deletions Week2/homework/map_filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
const numbers = [1, 2, 3, 4];

// Add your code here
const newNumbers = numbers
.filter(newNumber => newNumber % 2 !== 0)
.map(newNumber => newNumber * 2);

console.log(newNumbers);