diff --git a/Week1/homework/app.js b/Week1/homework/app.js index a9b5f75d8..e69de29bb 100644 --- a/Week1/homework/app.js +++ b/Week1/homework/app.js @@ -1,11 +0,0 @@ -'use strict'; - -{ - const bookTitles = [ - // Replace with your own book titles - 'harry_potter_chamber_secrets', - ]; - - // Replace with your own code - console.log(bookTitles); -} diff --git a/Week1/homework/index.html b/Week1/homework/index.html index b22147cd1..e69de29bb 100644 --- a/Week1/homework/index.html +++ b/Week1/homework/index.html @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/Week1/homework/style.css b/Week1/homework/style.css index bab13ec23..e69de29bb 100644 --- a/Week1/homework/style.css +++ b/Week1/homework/style.css @@ -1 +0,0 @@ -/* add your styling here */ \ No newline at end of file diff --git a/Week2/homework/maartjes-work.js b/Week2/homework/maartjes-work.js index 49772eb44..0c00bf73c 100644 --- a/Week2/homework/maartjes-work.js +++ b/Week2/homework/maartjes-work.js @@ -45,17 +45,36 @@ const tuesday = [ const maartjesTasks = monday.concat(tuesday); const maartjesHourlyRate = 20; -function computeEarnings(tasks, hourlyRate) { - // Replace this comment and the next line with your code - console.log(tasks, hourlyRate); -} +/* const computeEarnings = (tasks, hourlyRate) => { + let totalMins = 0; + for (let i = 0; i < tasks.length; i++) { + if (tasks[i].duration >= 120) { + totalMins += tasks[i].duration; + } + } + const hours = totalMins / 60; + return hours * hourlyRate; +}; */ + +const computeEarnings = (tasks, hourlyRate) => { + const hours = tasks.filter(function(task) { + return task.duration >= 120; + }); + const total = hours.map(function(time) { + return time.duration / 60; + }); + function sumofArray(sum, num) { + return sum + num; + } + return total.reduce(sumofArray) * hourlyRate; +}; // eslint-disable-next-line no-unused-vars const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate); // add code to convert `earnings` to a string rounded to two decimals (euro cents) -console.log(`Maartje has earned €${'replace this string with the earnings rounded to euro cents'}`); +console.log(`Maartje has earned €${Math.round((earnings + 0.00001) * 100) / 100}`); // Do not change or remove anything below this line module.exports = { diff --git a/Week2/homework/map-filter.js b/Week2/homework/map-filter.js index c8e8a88c1..4e83bcf99 100644 --- a/Week2/homework/map-filter.js +++ b/Week2/homework/map-filter.js @@ -1,11 +1,17 @@ 'use strict'; -function doubleOddNumbers(numbers) { - // Replace this comment and the next line with your code - console.log(numbers); -} - const myNumbers = [1, 2, 3, 4]; + +const doubleOddNumbers = numbers => { + const odds = numbers.filter(function(number) { + return number % 2 !== 0; + }); + const doubles = odds.map(function(number) { + return number * 2; + }); + return doubles; +}; + console.log(doubleOddNumbers(myNumbers)); // Do not change or remove anything below this line diff --git a/package-lock.json b/package-lock.json index e89e9916d..2b047f93a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2221,12 +2221,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -2241,17 +2243,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -2368,7 +2373,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -2380,6 +2386,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -2394,6 +2401,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -2401,12 +2409,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -2425,6 +2435,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -2505,7 +2516,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -2517,6 +2529,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -2638,6 +2651,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",