Skip to content

Commit 23784be

Browse files
committed
Changes Week1 and Week2
1 parent fd214b0 commit 23784be

6 files changed

Lines changed: 1782 additions & 2033 deletions

File tree

Week1/homework/app.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ const bookTitles = [
1919

2020
// Create ul element and assign id
2121

22-
const ul = document.createElement('ol');
22+
const ul = document.createElement('ul');
23+
ul.setAttribute('id', 'booktitle');
2324

2425
// eslint-disable-next-line no-unused-vars
2526
function createBookList(bookId) {
@@ -111,7 +112,7 @@ function createBookListUsingObject(bookObj) {
111112
li.appendChild(head);
112113
li.appendChild(headLanguageContent);
113114
li.appendChild(headAuthor);
114-
document.write('<br>');
115+
li.style.cssFloat = 'left';
115116

116117
ul.appendChild(li);
117118

@@ -149,3 +150,30 @@ function imageDisplay(imageObject) {
149150
}
150151

151152
imageDisplay(bookimage);
153+
154+
// eslint-disable-next-line no-undef
155+
ul.style.display = 'grid';
156+
ul.style.gridTemplateColumns = 'auto auto';
157+
ul.style.gridAutoColumns = 'minmax(auto,auto)';
158+
ul.style.gridAutoRows = 'minmax(auto,auto)';
159+
160+
// eslint-disable-next-line no-unused-vars
161+
function createGrid(x) {
162+
for (let rows = 0; rows < x; rows++) {
163+
for (let col = 0; col < x; col++) {
164+
// eslint-disable-next-line no-undef
165+
// $('#booktitle').append("<div> class='grid'></div>");
166+
const grid = document.getElementById("booktitle");
167+
grid.appendChild(li)
168+
}
169+
}
170+
171+
// eslint-disable-next-line no-undef
172+
$('.grid').height(960 / x);
173+
// eslint-disable-next-line no-undef
174+
$('.grid').width(960 / x);
175+
}
176+
177+
// eslint-disable-next-line no-undef
178+
createGrid(2);
179+
*/

Week2/homework/maartjes-work.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,19 @@ const tuesday = [
4545
const maartjesTasks = monday.concat(tuesday);
4646
const maartjesHourlyRate = 20;
4747

48-
function computeEarnings(tasks, hourlyRate) {
49-
// Replace this comment and the next line with your code
50-
console.log(tasks, hourlyRate);
51-
}
48+
const computeEarnings = maartjesTasks
49+
.map(tasks => [tasks.duration] / 60)
50+
.filter(duration => [duration] >= 2)
51+
.map(duration => duration * maartjesHourlyRate)
52+
.reduce((prev, curr) => [+prev + +curr])
53+
.map(amount => '€' + amount.toFixed(2));
54+
55+
console.log(computeEarnings);
56+
57+
// /function computeEarnings(tasks, hourlyRate) {
58+
// Replace this comment and the next line with your code
59+
// console.log(tasks, hourlyRate);
60+
// }
5261

5362
// eslint-disable-next-line no-unused-vars
5463
const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate);

Week2/homework/map-filter.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
'use strict';
22

3-
function doubleOddNumbers(numbers) {
4-
// Replace this comment and the next line with your code
5-
console.log(numbers);
6-
}
7-
83
const myNumbers = [1, 2, 3, 4];
9-
console.log(doubleOddNumbers(myNumbers));
4+
5+
/* function doubleOddNumbers(numbers) {
6+
// // Replace this comment and the next line with your code
7+
const newNumbers = [];
8+
for (let i = 0; i < numbers.length; i++) {
9+
if (numbers[i] % 2 !== 0) {
10+
newNumbers.push(numbers[i] * 2);
11+
}
12+
}
13+
return newNumbers;
14+
} */
15+
16+
const doubleOddNumbers = myNumbers.filter(numbers => numbers % 2 !== 0).map(numbers => numbers * 2);
17+
// eslint-disable-next-line no-unused-vars
18+
const result = doubleOddNumbers(myNumbers);
19+
console.log(result);
1020

1121
// Do not change or remove anything below this line
1222
module.exports = {

Week2/test/map-filter.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { myNumbers, doubleOddNumbers } = require(`../homework/map-filter`);
1+
const { myNumbers, doubleOddNumbers } = require(`../homework/map-filter`).default;
22

33
describe('map_filter', () => {
44
test('result -> [2, 6]', () => {

0 commit comments

Comments
 (0)