Skip to content

Commit 7cfa2fd

Browse files
committed
Updated Week1 and Week2 Homework
Adding homework as per new submission style
1 parent 9fe972b commit 7cfa2fd

5 files changed

Lines changed: 113 additions & 14 deletions

File tree

Week2/homework/Doublenumbertest.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
function doubleOddNumbers(numbers) {
2+
// Replace this comment and the next line with your code
3+
numbers.map(v % 2 !== 0 ? v * 2 : v);
4+
5+
console.log(numbers);
6+
}
7+
8+
let totalYears = numbers.reduce(function(accumulator, pilot) {
9+
return accumulator + pilot.years;
10+
}, 0);

Week2/homework/doublestuff.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const myNumbers = [1, 2, 3, 4];
2+
3+
function doubleOdd(numbers) {
4+
return numbers.map(number => (number % 2 !== 0 ? number * 2 : number));
5+
}
6+
console.log(doubleOdd(myNumbers));

Week2/homework/reduce.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const array1 = [1, 2, 3, 4];
2+
const reducer = (accumulator, currentValue) => accumulator * currentValue;
3+
4+
// 1 + 2 + 3 + 4
5+
console.log(array1.reduce(reducer, 0));
6+
// expected output: 10
7+
8+
// 5 + 1 + 2 + 3 + 4
9+
console.log(array1.reduce(reducer, 5));
10+
// expected output: 15

Week2/homework/timesheet-test.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
'use strict';
2+
3+
const monday = [
4+
{
5+
name: 'Write a summary HTML/CSS',
6+
duration: 180,
7+
},
8+
{
9+
name: 'Some web development',
10+
duration: 120,
11+
},
12+
{
13+
name: 'Fix homework for class10',
14+
duration: 20,
15+
},
16+
{
17+
name: 'Talk to a lot of people',
18+
duration: 200,
19+
},
20+
];
21+
22+
const tuesday = [
23+
{
24+
name: 'Keep writing summary',
25+
duration: 240,
26+
},
27+
{
28+
name: 'Some more web development',
29+
duration: 180,
30+
},
31+
{
32+
name: 'Staring out the window',
33+
duration: 10,
34+
},
35+
{
36+
name: 'Talk to a lot of people',
37+
duration: 200,
38+
},
39+
{
40+
name: 'Look at application assignments new students',
41+
duration: 40,
42+
},
43+
];
44+
45+
const maartjesTasks = monday.concat(tuesday);
46+
const maartjesHourlyRate = 20;
47+
const reducer = (accumulator, currentValue) => accumulator + currentValue;
48+
49+
function computeEarnings(tasks, hourlyRate) {
50+
const taskCost = tasks
51+
.map(task => task.duration / 60)
52+
.filter(task => task > 2)
53+
.map(task => task * hourlyRate)
54+
.reduce(reducer, 0);
55+
return taskCost.toFixed(2);
56+
}
57+
58+
const taskCost = computeEarnings(maartjesTasks, maartjesHourlyRate);
59+
60+
// eslint-disable-next-line no-unused-vars
61+
62+
// add code to convert `earnings` to a string rounded to two decimals (euro cents)
63+
64+
console.log(`Maartje has earned ${taskCost} euros`);
65+
66+
// Do not change or remove anything below this line
67+
module.exports = {
68+
maartjesTasks,
69+
maartjesHourlyRate,
70+
computeEarnings,
71+
};

Week3/homework/step2-2.js

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

33
function threeFive(startIndex, stopIndex, threeCallback, fiveCallback) {
4-
const numbers = [];
4+
function makeNumbers {
5+
const numbers = [];
6+
for (let i = startIndex; i <= stopIndex; i++) {
7+
numbers.push(i);
8+
}
9+
}
510

6-
// Replace this comment and the next line with your code
7-
console.log(startIndex, stopIndex, threeCallback, fiveCallback, numbers);
8-
}
9-
10-
function sayThree(number) {
11-
// Replace this comment and the next line with your code
12-
console.log(number);
13-
}
11+
function sayThree(number) {
12+
const isThree = (numbers = > (number % 3 == 0 ? threeCallback : number))
13+
return isThree
14+
15+
//}
1416

15-
function sayFive(number) {
16-
// Replace this comment and the next line with your code
17-
console.log(number);
17+
function sayFive(number) {
18+
// Replace this comment and the next line with your code
19+
console.log(number);
20+
}
1821
}
19-
20-
threeFive(10, 15, sayThree, sayFive);
22+
//threeFive(10, 15, sayThree, sayFive);
2123

2224
// Do not change or remove anything below this line
2325
module.exports = threeFive;

0 commit comments

Comments
 (0)