diff --git a/week 2 b/week 2 new file mode 100644 index 000000000..8566707c8 --- /dev/null +++ b/week 2 @@ -0,0 +1,7 @@ +Step 1: + +const numbers = [1, 2, 3, 4]; +const oddnumbers = numbers.filter(item => Math.abs(item) % 2 === 1) +const doubleOddNumbers = oddnumbers.map(item => item * 2) + +console.log(doubleOddNumbers) diff --git a/week_2 b/week_2 new file mode 100644 index 000000000..9a07a717b --- /dev/null +++ b/week_2 @@ -0,0 +1,73 @@ +1.1 + +function doubleOddNumbers(numbers) { + console.log(numbers); + return numbers.filter(num => num % 2 !== 0).map(num => num * 2); + } + const myNumbers = [1, 2, 3, 4]; + console.log(doubleOddNumbers(myNumbers)); + + + + + 1.2 + + const monday = [ + { + name: "Write a summary HTML/CSS", + duration: 180 + }, + { + name: "Some web development", + duration: 120 + }, + { + name: "Fix homework for class10", + duration: 20 + }, + { + name: "Talk to a lot of people", + duration: 200 + } +]; + +const tuesday = [ + { + name: "Keep writing summary", + duration: 240 + }, + { + name: "Some more web development", + duration: 180 + }, + { + name: "Staring out the window", + duration: 10 + }, + { + name: "Talk to a lot of people", + duration: 200 + }, + { + name: "Look at application assignments new students", + duration: 40 + } +]; + +const tasks = [...monday, ...tuesday]; +const rate = 20; +const tasksInHour = tasks + .map(i => i.duration / 60) + .filter(i => i >= 2) + .map(i => i * rate) + .reduce((total, value) => total + value) + .toFixed(2); + +console.log(`€ ${tasksInHour}`); + +// 60, 40, 66.66666, 80, 60, 66.6666 +// total , value , result +// iteration 0 ... total = 60, value = 40 ---> 100 +// iteration 1 ... total = 100, value = 66.66 --> 166.666 +// iteration 2 ... total = 166.666, value = 80 --> 246.666 +// iteration n .. total = something number