Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Week03 #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
81 changes: 73 additions & 8 deletions Week1/homework/app.js
Original file line number Diff line number Diff line change
@@ -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 = `<li>${bookInfo.key}</li>`;
Binary file added Week1/homework/eli.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion Week1/homework/index.html
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
<!-- replace this with your HTML content -->
<!DOCTYPE html>
<html>

<head>
<title>Elia Books</title>
</head>
<p id="books"></p>
<div id="inf"></div>

<body>
<script src="app.js">
</script>
</body>

</html>
38 changes: 20 additions & 18 deletions Week2/homework/maartjes-work.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const monday = [
{
const monday = [{
name: 'Write a summary HTML/CSS',
duration: 180,
},
Expand All @@ -19,8 +18,7 @@ const monday = [
},
];

const tuesday = [
{
const tuesday = [{
name: 'Keep writing summary',
duration: 240,
},
Expand All @@ -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,
};
16 changes: 11 additions & 5 deletions Week2/homework/map-filter.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 10 additions & 8 deletions Week3/homework/step2-1.js
Original file line number Diff line number Diff line change
@@ -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;
24 changes: 15 additions & 9 deletions Week3/homework/step2-2.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
23 changes: 16 additions & 7 deletions Week3/homework/step2-3.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down
6 changes: 4 additions & 2 deletions Week3/homework/step2-4.js
Original file line number Diff line number Diff line change
@@ -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;
15 changes: 11 additions & 4 deletions Week3/homework/step2-5.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Loading