diff --git a/Week1/homework/app.js b/Week1/homework/app.js
index a9b5f75d8..25a21035e 100644
--- a/Week1/homework/app.js
+++ b/Week1/homework/app.js
@@ -1,11 +1,76 @@
-'use strict';
+//make an array
-{
- const bookTitles = [
- // Replace with your own book titles
- 'harry_potter_chamber_secrets',
- ];
+/*const bookList = [
+ 'elia1',
+ 'elia2',
+ 'elia3',
+ 'elia4',
+ 'elia5',
+ 'elia6',
+ 'elia7',
+ 'elia7',
+ 'elia8',
+ 'elia9',
+ 'elia10',
+];
- // Replace with your own code
- console.log(bookTitles);
+//console.log(bookList);
+
+//creat UL
+
+//make an object containing info
+
+let ul = document.createElement('ul');
+document.getElementById('books').appendChild(ul);
+
+bookList.forEach(book => {
+ let li = document.createElement('li');
+ ul.appendChild(li);
+ li.innerHTML += book;
+});
+*/
+
+const bookInfo = {
+ 'Elia1': {
+ properties: {
+ name: 'Elia 1',
+ Author: 'Elia the Famouse',
+ Language: 'English',
+ img: 'eli.jpg',
+ },
+ },
+ 'Elia2': {
+ properties: {
+ name: 'Elia 2',
+ Author: 'Elia the Famouse',
+ Language: 'English',
+ img: 'eli.jpg',
+ },
+ },
+ 'Elia3': {
+ properties: {
+ name: 'Elia 3',
+ Author: 'Elia the Famouse',
+ Language: 'English',
+ img: 'eli.jpg',
+ },
+ },
+ 'Elia4': {
+ properties: {
+ name: 'Elia 4',
+ Author: 'Elia the Famouse',
+ Language: 'English',
+ img: 'eli.jpg',
+ },
+ },
+ 'Elia5': {
+ properties: {
+ name: 'Elia 5',
+ Author: 'Elia the Famouse',
+ Language: 'English',
+ img: 'eli.jpg',
+ },
+ }
}
+
+document.getElementById('inf').innerHTML = `
${bookInfo.key}`;
\ No newline at end of file
diff --git a/Week1/homework/eli.jpg b/Week1/homework/eli.jpg
new file mode 100644
index 000000000..1b4be99ea
Binary files /dev/null and b/Week1/homework/eli.jpg differ
diff --git a/Week1/homework/index.html b/Week1/homework/index.html
index b22147cd1..e195ab500 100644
--- a/Week1/homework/index.html
+++ b/Week1/homework/index.html
@@ -1 +1,15 @@
-
\ No newline at end of file
+
+
+
+
+ Elia Books
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Week2/homework/maartjes-work.js b/Week2/homework/maartjes-work.js
index 49772eb44..9f4c84959 100644
--- a/Week2/homework/maartjes-work.js
+++ b/Week2/homework/maartjes-work.js
@@ -1,7 +1,6 @@
'use strict';
-const monday = [
- {
+const monday = [{
name: 'Write a summary HTML/CSS',
duration: 180,
},
@@ -19,8 +18,7 @@ const monday = [
},
];
-const tuesday = [
- {
+const tuesday = [{
name: 'Keep writing summary',
duration: 240,
},
@@ -42,24 +40,28 @@ const tuesday = [
},
];
-const maartjesTasks = monday.concat(tuesday);
+const tasks = monday.concat(tuesday);
const maartjesHourlyRate = 20;
+// eslint-disable-next-line no-unused-vars
+const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate)
+
+
function computeEarnings(tasks, hourlyRate) {
- // Replace this comment and the next line with your code
- console.log(tasks, hourlyRate);
-}
+ const taskHours = tasks.map(hours => tasks.duration / 60).filter(hours => hours <= 2);
+ const euroRates = taskHours.map(hours => hours * maartjesHourlyRate);
+
+
+
-// 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)
+ // 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 €${'replace this string with the earnings rounded to euro cents'}`);
-// Do not change or remove anything below this line
-module.exports = {
- maartjesTasks,
- maartjesHourlyRate,
- computeEarnings,
-};
+ // Do not change or remove anything below this line
+ module.exports = {
+ maartjesTasks,
+ maartjesHourlyRate,
+ computeEarnings,
+ };
\ No newline at end of file
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/Week3/homework/step2-1.js b/Week3/homework/step2-1.js
index d5699882c..ae4b83f0e 100644
--- a/Week3/homework/step2-1.js
+++ b/Week3/homework/step2-1.js
@@ -1,16 +1,18 @@
'use strict';
-function foo(func) {
- // What to do here?
- // Replace this comment and the next line with your code
- console.log(func);
-}
+function foo(bar) {
+ function bar() {
+ console.log('Hello, I am bar!');
+ }
+
+ console.log('Week3');
-function bar() {
- console.log('Hello, I am bar!');
}
+
+
foo(bar);
+
// Do not change or remove anything below this line
-module.exports = foo;
+module.exports = foo;
\ No newline at end of file
diff --git a/Week3/homework/step2-2.js b/Week3/homework/step2-2.js
index dcd135040..66cb5d2c1 100644
--- a/Week3/homework/step2-2.js
+++ b/Week3/homework/step2-2.js
@@ -2,22 +2,28 @@
function threeFive(startIndex, stopIndex, threeCallback, fiveCallback) {
const numbers = [];
-
- // Replace this comment and the next line with your code
- console.log(startIndex, stopIndex, threeCallback, fiveCallback, numbers);
+ for (let i = startIndex; i <= stopIndex; i++) {
+ numbers.push(i);
+ if (i % 3 === 0) {
+ threeCallback(i);
+ }
+ if (i % 5 === 0) {
+ fiveCallback(i);
+ }
+ }
}
function sayThree(number) {
- // Replace this comment and the next line with your code
- console.log(number);
-}
+ console.log('${number} is divisible by three')
+
+};
function sayFive(number) {
- // Replace this comment and the next line with your code
- console.log(number);
+
+ console.log('${number} is divisible by five');
}
threeFive(10, 15, sayThree, sayFive);
// Do not change or remove anything below this line
-module.exports = threeFive;
+module.exports = threeFive;
\ No newline at end of file
diff --git a/Week3/homework/step2-3.js b/Week3/homework/step2-3.js
index 00845c5eb..49fcabd76 100644
--- a/Week3/homework/step2-3.js
+++ b/Week3/homework/step2-3.js
@@ -5,21 +5,27 @@ function repeatStringNumTimesWithFor(str, num) {
// eslint-disable-next-line prefer-const
let result = '';
- // Replace this comment and the next line with your code
- console.log(str, num, result);
+ for (let i = 0; i < num; i++) {
+ result = +str;
+ num--;
+ }
return result;
}
-
+// but when I console.log it returns : for NaN!!!!
console.log('for', repeatStringNumTimesWithFor('abc', 3));
+/*************************************************************************/
+
// Use a 'while' loop
function repeatStringNumTimesWithWhile(str, num) {
// eslint-disable-next-line prefer-const
let result = '';
- // Replace this comment and the next line with your code
- console.log(str, num, result);
+ while (num > 0) {
+ result += str;
+ num--;
+ }
return result;
}
@@ -30,9 +36,12 @@ console.log('while', repeatStringNumTimesWithWhile('abc', 3));
function repeatStringNumTimesWithDoWhile(str, num) {
// eslint-disable-next-line prefer-const
let result = '';
+ let i = 0;
- // Replace this comment and the next line with your code
- console.log(str, num, result);
+ do {
+ result = +str;
+ i++;
+ } while (i < num);
return result;
}
diff --git a/Week3/homework/step2-4.js b/Week3/homework/step2-4.js
index b11b1dcb6..7bf3e904c 100644
--- a/Week3/homework/step2-4.js
+++ b/Week3/homework/step2-4.js
@@ -1,10 +1,12 @@
'use strict';
function Dog() {
- // add your code here
+ this.name = "Albert";
+ this.color = "brown";
+ this.numLegs = 4;
}
const hound = new Dog();
// Do not change or remove anything below this line
-module.exports = hound;
+module.exports = hound;
\ No newline at end of file
diff --git a/Week3/homework/step2-5.js b/Week3/homework/step2-5.js
index cbb54fa1d..9e2667018 100644
--- a/Week3/homework/step2-5.js
+++ b/Week3/homework/step2-5.js
@@ -4,14 +4,21 @@ function multiplyAll(arr) {
// eslint-disable-next-line
let product = 1;
- // Replace this comment and the next line with your code
- console.log(arr, product);
+ for (let i = 0; i < arr.length; i++) {
+ for (let j = 0; j < arr[i].length; j++) {
+ product = product * arr[i][j];
+ }
+ }
return product;
}
-const result = multiplyAll([[1, 2], [3, 4], [5, 6]]);
+const result = multiplyAll([
+ [1, 2],
+ [3, 4],
+ [5, 6]
+]);
console.log(result); // 720
// Do not change or remove anything below this line
-module.exports = multiplyAll;
+module.exports = multiplyAll;
\ No newline at end of file
diff --git a/Week3/homework/step2-6.js b/Week3/homework/step2-6.js
index ffe95b9f7..592baa0df 100644
--- a/Week3/homework/step2-6.js
+++ b/Week3/homework/step2-6.js
@@ -1,16 +1,44 @@
'use strict';
-const arr2d = [[1, 2], [3, 4], [5, 6]];
-const arr3d = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
+const arr2d = [
+ [1, 2],
+ [3, 4],
+ [5, 6]
+];
+const arr3d = [
+ [
+ [1, 2],
+ [3, 4]
+ ],
+ [
+ [5, 6],
+ [7, 8]
+ ]
+];
function flattenArray2d(arr) {
- // Replace this comment and the next line with your code
- console.log(arr);
+ let flattenArr2 = [];
+ for (let i = 0; i < arr.length; i++) {
+ for (let j = 0; j < arr[i].length; j++) {
+ flattenArr2.push(arr[i][j])
+ }
+ }
+ return flattenArr2;
}
+console.log(flattenArray2d(arr2d));
function flattenArray3d(arr) {
- // Replace this comment and the next line with your code
- console.log(arr);
+ const flattenArr3 = [];
+ for (let i = 0; i < arr.length; i++) {
+ for (let j = 0; j < arr[i].length; j++) {
+ for (let l = 0; l < arr[i][j].length; l++) {
+
+ flattenArr3.push(arr[i][j][l]);
+ }
+ }
+
+ }
+ return flattenArr3;
}
console.log(flattenArray2d(arr2d)); // -> [1, 2, 3, 4, 5, 6]
@@ -20,4 +48,4 @@ console.log(flattenArray3d(arr3d)); // -> [1, 2, 3, 4, 5, 6, 7, 8]
module.exports = {
flattenArray2d,
flattenArray3d,
-};
+};
\ No newline at end of file
diff --git a/Week3/homework/step2-7.js b/Week3/homework/step2-7.js
index 3e72e8551..289c4e1e2 100644
--- a/Week3/homework/step2-7.js
+++ b/Week3/homework/step2-7.js
@@ -1,6 +1,7 @@
'use strict';
const x = 9;
+
function f1(val) {
val = val + 1;
return val;
@@ -10,7 +11,10 @@ f1(x);
console.log(x);
-const y = { x: 9 };
+const y = {
+ x: 9
+};
+
function f2(val) {
val.x = val.x + 1;
return val;
@@ -21,3 +25,7 @@ f2(y);
console.log(y);
// Add your explanation as a comment here
+
+//the first function just changes the integer but we console.log the x which is 9.
+//the second function takes the value 'y' which is an object. It takes the value of x but then it updates the x
+//to become 10 and indeed it updated the 'y'to become equal to 10 as well.
\ No newline at end of file
diff --git a/Week3/homework/step3-bonus.js b/Week3/homework/step3-bonus.js
index 917091d61..cfee8909a 100644
--- a/Week3/homework/step3-bonus.js
+++ b/Week3/homework/step3-bonus.js
@@ -3,12 +3,12 @@
const values = ['a', 'b', 'c', 'd', 'a', 'e', 'f', 'c'];
function makeUnique(arr) {
- // Replace this comment and the next line with your code
- console.log(arr);
+ return Array.from(new Set(arr));
+
}
const uniqueValues = makeUnique(values);
console.log(uniqueValues);
// Do not change or remove anything below this line
-module.exports = makeUnique;
+module.exports = makeUnique;
\ No newline at end of file
diff --git a/Week3/homework/step3.js b/Week3/homework/step3.js
index 292724bf4..3ddcabeb0 100644
--- a/Week3/homework/step3.js
+++ b/Week3/homework/step3.js
@@ -1,8 +1,11 @@
'use strict';
function createBase(base) {
- // Replace this comment and the next line with your code
- console.log(base);
+
+ const addNum = function (num) {
+ return base + num;
+ };
+ return addNum;
}
const addSix = createBase(6);
@@ -10,5 +13,5 @@ const addSix = createBase(6);
console.log(addSix(10)); // returns 16
console.log(addSix(21)); // returns 27
-// Do not change or remove anything below this line
-module.exports = createBase;
+// Do not change or remove anything below this line.
+module.exports = createBase;
\ No newline at end of file