@@ -7,9 +7,9 @@ let numbers = [1, 2, 3, 4];
7
7
let newNumbers = [ ] ;
8
8
9
9
for ( let i = 0 ; i < numbers . length ; i ++ ) {
10
- if ( numbers [ i ] % 2 !== 0 ) {
11
- newNumbers . push ( numbers [ i ] * 2 ) ;
12
- }
10
+ if ( numbers [ i ] % 2 !== 0 ) {
11
+ newNumbers . push ( numbers [ i ] * 2 ) ;
12
+ }
13
13
}
14
14
15
15
console . log ( "The doubled numbers are" , newNumbers ) ; // [2, 6]
@@ -29,18 +29,18 @@ console.log("The doubled numbers are: " + times2);
29
29
//Underneath you see a very interesting small insight in Maartje's work:
30
30
31
31
let monday = [
32
- { name : 'Write a summary HTML/CSS' , duration : 180 } ,
33
- { name : 'Some web development' , duration : 120 } ,
34
- { name : 'Fix homework for class10' , duration : 20 } ,
35
- { name : 'Talk to a lot of people' , duration : 200 }
32
+ { name : 'Write a summary HTML/CSS' , duration : 180 } ,
33
+ { name : 'Some web development' , duration : 120 } ,
34
+ { name : 'Fix homework for class10' , duration : 20 } ,
35
+ { name : 'Talk to a lot of people' , duration : 200 }
36
36
] ;
37
37
38
38
let tuesday = [
39
- { name : 'Keep writing summary' , duration : 240 } ,
40
- { name : 'Some more web development' , duration : 180 } ,
41
- { name : 'Staring out the window' , duration : 10 } ,
42
- { name : 'Talk to a lot of people' , duration : 200 } ,
43
- { name : 'Look at application assignments new students' , duration : 40 }
39
+ { name : 'Keep writing summary' , duration : 240 } ,
40
+ { name : 'Some more web development' , duration : 180 } ,
41
+ { name : 'Staring out the window' , duration : 10 } ,
42
+ { name : 'Talk to a lot of people' , duration : 200 } ,
43
+ { name : 'Look at application assignments new students' , duration : 40 }
44
44
] ;
45
45
46
46
let tasks = monday . concat ( tuesday ) ;
@@ -49,39 +49,39 @@ console.log(tasks);
49
49
// 2) Write a program that does the following below. Use map and filter. You will also need a forEach or a for loop for the 'summing up' part.
50
50
/*Collect two days' worth of tasks.
51
51
Convert the task durations to hours, instead of minutes.
52
- Filter out everything that took two hours or more ( remove from the collection)
52
+ Filter out everything that took less than two hours (i.e., remove from the collection)
53
53
Multiply the each duration by a per-hour rate for billing (you can decide yourself what Maartje should make per hour) and sum it all up.
54
54
Output a formatted Euro amount.
55
55
Don't forget to use => */
56
56
let thursday = [
57
- { activity : "get kids ready for school" , hours : 1 } ,
58
- { activity : "drop off/pick up kids at school" , hours : 1 } ,
59
- { activity : "attend a meetup" , hours : 3 } ,
60
- { activity : "study for HYF" , hours : 5 } ,
61
- { activity : "cook dinner" , hours : 1 } ,
62
- { activity : "kid's bedtime routine" , hours : 1 } ,
63
- { activity : "relax, watch tv" , hours : 3 } ,
57
+ { activity : "get kids ready for school" , hours : 1 } ,
58
+ { activity : "drop off/pick up kids at school" , hours : 1 } ,
59
+ { activity : "attend a meetup" , hours : 3 } ,
60
+ { activity : "study for HYF" , hours : 5 } ,
61
+ { activity : "cook dinner" , hours : 1 } ,
62
+ { activity : "kid's bedtime routine" , hours : 1 } ,
63
+ { activity : "relax, watch tv" , hours : 3 } ,
64
64
] ;
65
65
let friday = [
66
- { activity : "get kids ready for school" , hours : 1 } ,
67
- { activity : "drop off/pick up kids at school" , hours : 1 } ,
68
- { activity : "study for HYF" , hours : 8 } ,
69
- { activity : "cook dinner" , hours : 1 } ,
70
- { activity : "kid's bedtime routine" , hours : 1 } ,
71
- { activity : "go out with friends" , hours : 4 } ,
66
+ { activity : "get kids ready for school" , hours : 1 } ,
67
+ { activity : "drop off/pick up kids at school" , hours : 1 } ,
68
+ { activity : "study for HYF" , hours : 8 } ,
69
+ { activity : "cook dinner" , hours : 1 } ,
70
+ { activity : "kid's bedtime routine" , hours : 1 } ,
71
+ { activity : "go out with friends" , hours : 4 } ,
72
72
] ;
73
73
let activities = thursday . concat ( friday ) ; //combines both arrays
74
74
//console.log(activities);
75
75
76
- let underTwo = activities . filter ( item => item . hours < = 2 ) ; // creates a new array that only includes the activities that were under 2 hours
77
- //console.log(underTwo);
76
+ let overTwo = activities . filter ( item => item . hours > = 2 ) ; // creates a new array that only includes the activities that took 2 hours or more
77
+ //console.log(overTwo);
78
78
79
- let hourlyRates = underTwo . map ( item => item . hours * 25.00 ) ; // creates an array with the hourly rates
79
+ let hourlyRates = underTwo . map ( item => item . hours * 25.00 ) ; // creates an array with the hourly rates
80
80
//console.log(hourlyRates);
81
81
82
- let payment = hourlyRates . reduce ( ( accumulator , currentValue ) => accumulator + currentValue ) ; //reduces payment to 200 which is all the hourly rates combined
82
+ let payment = hourlyRates . reduce ( ( accumulator , currentValue ) => accumulator + currentValue ) ; //reduces payment to 200 which is all the hourly rates combined
83
83
84
- let totalEuros = payment . toLocaleString ( 'en-US' , { style : 'currency' , currency : 'EUR' } ) ;
84
+ let totalEuros = payment . toLocaleString ( 'en-US' , { style : 'currency' , currency : 'EUR' } ) ;
85
85
//console.log(totalEuros); //200 euros
86
86
87
87
console . log ( "I would get paid: " + totalEuros ) ;
0 commit comments