|
| 1 | +1.1 |
| 2 | + |
| 3 | +function doubleOddNumbers(numbers) { |
| 4 | + console.log(numbers); |
| 5 | + return numbers.filter(num => num % 2 !== 0).map(num => num * 2); |
| 6 | + } |
| 7 | + const myNumbers = [1, 2, 3, 4]; |
| 8 | + console.log(doubleOddNumbers(myNumbers)); |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + 1.2 |
| 14 | + |
| 15 | + const monday = [ |
| 16 | + { |
| 17 | + name: "Write a summary HTML/CSS", |
| 18 | + duration: 180 |
| 19 | + }, |
| 20 | + { |
| 21 | + name: "Some web development", |
| 22 | + duration: 120 |
| 23 | + }, |
| 24 | + { |
| 25 | + name: "Fix homework for class10", |
| 26 | + duration: 20 |
| 27 | + }, |
| 28 | + { |
| 29 | + name: "Talk to a lot of people", |
| 30 | + duration: 200 |
| 31 | + } |
| 32 | +]; |
| 33 | + |
| 34 | +const tuesday = [ |
| 35 | + { |
| 36 | + name: "Keep writing summary", |
| 37 | + duration: 240 |
| 38 | + }, |
| 39 | + { |
| 40 | + name: "Some more web development", |
| 41 | + duration: 180 |
| 42 | + }, |
| 43 | + { |
| 44 | + name: "Staring out the window", |
| 45 | + duration: 10 |
| 46 | + }, |
| 47 | + { |
| 48 | + name: "Talk to a lot of people", |
| 49 | + duration: 200 |
| 50 | + }, |
| 51 | + { |
| 52 | + name: "Look at application assignments new students", |
| 53 | + duration: 40 |
| 54 | + } |
| 55 | +]; |
| 56 | + |
| 57 | +const tasks = [...monday, ...tuesday]; |
| 58 | +const rate = 20; |
| 59 | +const tasksInHour = tasks |
| 60 | + .map(i => i.duration / 60) |
| 61 | + .filter(i => i >= 2) |
| 62 | + .map(i => i * rate) |
| 63 | + .reduce((total, value) => total + value) |
| 64 | + .toFixed(2); |
| 65 | + |
| 66 | +console.log(`€ ${tasksInHour}`); |
| 67 | + |
| 68 | +// 60, 40, 66.66666, 80, 60, 66.6666 |
| 69 | +// total , value , result |
| 70 | +// iteration 0 ... total = 60, value = 40 ---> 100 |
| 71 | +// iteration 1 ... total = 100, value = 66.66 --> 166.666 |
| 72 | +// iteration 2 ... total = 166.666, value = 80 --> 246.666 |
| 73 | +// iteration n .. total = something number |
0 commit comments