diff --git a/Week1/homework/app.js b/Week1/homework/app.js index 6131f54ea..48d9e718f 100644 --- a/Week1/homework/app.js +++ b/Week1/homework/app.js @@ -1,11 +1,123 @@ 'use strict'; { - const bookTitles = [ - // Replace with your own book titles - 'harry_potter_chamber_secrets' - ]; + function main() { + const listBooks = [ + 'id_book_one', + 'id_book_two', + 'id_book_three', + 'id_book_four', + 'id_book_five', + 'id_book_six', + 'id_book_seven', + 'id_book_eight', + 'id_book_nine', + 'id_book_ten' + ]; - // Replace with your own code - console.log(bookTitles); + const information = { + id_book_one: { + author: 'Kevin Brockmeier', + language: 'english', + name: 'The Brief History of the Dead', + Artist: 'Archie Ferguson' + }, + id_book_two: { + author: 'Bret Easton Ellis', + language: 'english', + name: ' American Psycho', + Artist: 'Marshall Arisman' + }, + id_book_three: { + author: 'Jon Ronson', + language: 'english', + name: 'Columbine', + Artist: 'Henry Sene Yee' + }, + id_book_four: { + author: 'Jon Ronson', + language: 'english', + name: 'The Psychopath Test', + Artist: 'Alex Merto' + }, + id_book_five: { + author: 'Albert Camus', + language: 'english', + name: 'The Stranger', + Artist: 'Helen Yentus' + }, + id_book_six: { + author: 'The Road', + language: 'english', + name: 'The Road', + Artist: 'Nick Lowndes' + }, + id_book_seven: { + author: 'Jim Th', + language: 'english', + name: 'Heed The Thunder', + Artist: 'Unknown' + }, + id_book_eight: { + author: 'James Hawes', + language: 'english', + name: 'You Should Read', + Artist: 'Steve Snider' + }, + id_book_nine: { + author: 'The Humbling', + language: 'english', + name: 'The Humbling', + Artist: 'Milton Glaser' + }, + id_book_ten: { + author: 'F. Scott Fitzgerald', + language: 'english', + name: 'he Great Gatsby', + Artist: 'Unknown' + } + }; + const image = { + id_book_one: './image/id_book_one.jpg', + id_book_two: './image/id_book_two.jpg', + id_book_three: './image/id_book_three.jpg', + id_book_four: './image/id_book_four.jpg', + id_book_five: './image/id_book_five.jpg', + id_book_six: './image/id_book_six.jpg', + id_book_seven: './image/id_book_seven.jpg', + id_book_eight: './image/id_book_eight.jpg', + id_book_nine: './image/id_book_nine.jpg', + id_book_ten: './image/id_book_ten.jpg' + }; + const div = document.getElementById('container'); + + const h1Tag = document.createElement('h1'); + h1Tag.innerHTML = 'My Favourite Books'; + div.appendChild(h1Tag); + h1Tag.className = 'h1Tag'; + + const divTag = document.createElement('div'); + divTag.className = 'myBooks'; + + const ulTag = document.createElement('ul'); + ulTag.className = 'books'; + listBooks.forEach(function(id) { + const img = document.createElement('img'); + img.src = image[id]; + img.className = 'cover'; + const title = document.createElement('h2'); + title.innerHTML = information[id].name; + title.className = 'title'; + const liTag = document.createElement('li'); + liTag.innerHTML = information[id].author; + liTag.className = 'book'; + liTag.appendChild(title); + liTag.appendChild(img); + ulTag.appendChild(liTag); + div.appendChild(divTag); + divTag.appendChild(ulTag); + }); + } + + window.addEventListener('load', main); } diff --git a/Week1/homework/image/id_book_eight.jpg b/Week1/homework/image/id_book_eight.jpg new file mode 100644 index 000000000..02add3500 Binary files /dev/null and b/Week1/homework/image/id_book_eight.jpg differ diff --git a/Week1/homework/image/id_book_five.jpg b/Week1/homework/image/id_book_five.jpg new file mode 100644 index 000000000..a4c3eee35 Binary files /dev/null and b/Week1/homework/image/id_book_five.jpg differ diff --git a/Week1/homework/image/id_book_four.jpg b/Week1/homework/image/id_book_four.jpg new file mode 100644 index 000000000..92fea5010 Binary files /dev/null and b/Week1/homework/image/id_book_four.jpg differ diff --git a/Week1/homework/image/id_book_nine.jpg b/Week1/homework/image/id_book_nine.jpg new file mode 100644 index 000000000..2bffed880 Binary files /dev/null and b/Week1/homework/image/id_book_nine.jpg differ diff --git a/Week1/homework/image/id_book_one.jpg b/Week1/homework/image/id_book_one.jpg new file mode 100644 index 000000000..46819baf3 Binary files /dev/null and b/Week1/homework/image/id_book_one.jpg differ diff --git a/Week1/homework/image/id_book_seven.jpg b/Week1/homework/image/id_book_seven.jpg new file mode 100644 index 000000000..3d998b264 Binary files /dev/null and b/Week1/homework/image/id_book_seven.jpg differ diff --git a/Week1/homework/image/id_book_six.jpg b/Week1/homework/image/id_book_six.jpg new file mode 100644 index 000000000..20a659776 Binary files /dev/null and b/Week1/homework/image/id_book_six.jpg differ diff --git a/Week1/homework/image/id_book_ten.jpg b/Week1/homework/image/id_book_ten.jpg new file mode 100644 index 000000000..5168c9315 Binary files /dev/null and b/Week1/homework/image/id_book_ten.jpg differ diff --git a/Week1/homework/image/id_book_three.jpg b/Week1/homework/image/id_book_three.jpg new file mode 100644 index 000000000..40772cca6 Binary files /dev/null and b/Week1/homework/image/id_book_three.jpg differ diff --git a/Week1/homework/image/id_book_two.jpg b/Week1/homework/image/id_book_two.jpg new file mode 100644 index 000000000..983cd8165 Binary files /dev/null and b/Week1/homework/image/id_book_two.jpg differ diff --git a/Week1/homework/index.html b/Week1/homework/index.html index b22147cd1..8a8d65711 100644 --- a/Week1/homework/index.html +++ b/Week1/homework/index.html @@ -1 +1,14 @@ - \ No newline at end of file + + + + + + Page Title + + + + + +
+ + diff --git a/Week1/homework/style.css b/Week1/homework/style.css index bab13ec23..2a3b65c51 100644 --- a/Week1/homework/style.css +++ b/Week1/homework/style.css @@ -1 +1,31 @@ -/* add your styling here */ \ No newline at end of file +body { + background-image: url('http://celb.lu/wp-content/uploads/2014/04/Gray-plain-website-background.jpg'); + width: 100%; +} +ul { + text-decoration-style: none; + display: flex; + justify-content: center; + flex-wrap: wrap; +} + +li { + list-style: none; + margin-top: 0px; + width: 300px; + height: 400px; + vertical-align: middle; +} +h1 { + text-align: center; + color: rgb(29, 124, 168); + font-size: 5em; +} +img { + width: 150px; + height: 200px; + border-radius: 30px; +} +.book { + margin: 30px 10px 5px 20px; +} diff --git a/Week2/homework/maartjes-work.js b/Week2/homework/maartjes-work.js index fc8c0e633..e65685d27 100644 --- a/Week2/homework/maartjes-work.js +++ b/Week2/homework/maartjes-work.js @@ -46,8 +46,13 @@ 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 totalEarning = tasks + console.log(tasks, hourlyRate); .map(x => x.duration / 60) + .filter(x => x >= 2) + .map(x => x * hourlyRate) + .reduce((accumulator, number) => accumulator + number); + return totalEarning; + } // eslint-disable-next-line no-unused-vars @@ -55,7 +60,7 @@ const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate); // add code to convert `earnings` to a string rounded to two decimals (euro cents) -console.log(`Maartje has earned €${'replace this string with the earnings rounded to euro cents'}`); +console.log(`Maartje has earned €${earnings.toFixed(2)}`); // 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 ab3c622d4..2f7921b67 100644 --- a/Week2/homework/map-filter.js +++ b/Week2/homework/map-filter.js @@ -1,8 +1,7 @@ 'use strict'; function doubleOddNumbers(numbers) { - // Replace this comment and the next line with your code - console.log(numbers); + return numbers.filter(x => x % 2 !== 0).map(x => x * 2); } const myNumbers = [1, 2, 3, 4];