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

Skip to content

Commit e1dec70

Browse files
committed
test1
1 parent f7d5940 commit e1dec70

File tree

6 files changed

+4018
-2570
lines changed

6 files changed

+4018
-2570
lines changed

Week1/homework/index.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,13 @@
1-
<!-- replace this with your HTML content -->
1+
<!-- replace this with your HTML content -->
2+
<!DOCTYPE html>
3+
<html lang="en">
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<title>Squirtle</title>
8+
<script src=""
9+
</head>
10+
<body>
11+
12+
</body>
13+
</html>

Week2/MAKEME.md

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,28 @@ _Deadline Wednesday_
1919
Your solution could be something like this:
2020

2121
```js
22-
function doubleOddNumbers(numbers) {
23-
const newNumbers = [];
24-
for (let i = 0; i < numbers.length; i++) {
25-
if (numbers[i] % 2 !== 0) {
26-
newNumbers.push(numbers[i] * 2);
27-
}
28-
}
29-
return newNumbers;
30-
}
31-
32-
const myNumbers = [1, 2, 3, 4];
33-
console.log(doubleOddNumbers(myNumbers)); // ==> [2, 6]
22+
//function doubleOddNumbers(numbers) {
23+
// const newNumbers = [];
24+
//for (let i = 0; i < numbers.length; i++) {
25+
//if (numbers[i] % 2 !== 0) {
26+
// newNumbers.push(numbers[i] * 2);
27+
// }
28+
// }
29+
// return newNumbers;
30+
//}
31+
32+
//const myNumbers = [1, 2, 3, 4];
33+
//console.log(doubleOddNumbers(myNumbers)); // ==> [2, 6]
3434
```
3535

36+
// Pass a function to map
37+
function doubleOddNumbers(){
38+
const numbers = [1,3,5,7,9,11]
39+
const doubled = numbers.map((number)=> number*2); // function inside array map is copying numbers values
40+
return doubled
41+
}
42+
const result = doubleOddNumbers()
43+
console.log(result);
3644
Rewrite the above `doubleOddNumbers` function using `map` and `filter`; don't forget to use `=>`.
3745

3846
---

Week2/homework/maartjes-work.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const monday = [
1414
duration: 20,
1515
},
1616
{
17-
name: 'Talk to a lot of people!',
17+
name: 'Talk to a lot of people',
1818
duration: 200,
1919
},
2020
];
@@ -45,17 +45,25 @@ const tuesday = [
4545
const maartjesTasks = monday.concat(tuesday);
4646
const maartjesHourlyRate = 20;
4747

48-
function computeEarnings(tasks, hourlyRate) {
48+
//function computeEarnings(tasks, hourlyRate) {
4949
// Replace this comment and the next line with your code
50-
console.log(tasks, hourlyRate);
51-
}
50+
51+
// console.log(tasks, hourlyRate);
52+
//}
53+
54+
function computeEarnings(tasks, hourlyRate){
55+
const computeEarnings = (tasks, hourlyRate) => {
56+
const durationsInHours = maartjesTasks.map(task => task.duration / 60);
57+
const filteredHours = durationsInHours.filter(hour => hour >= 2);
58+
const totalEarnings = filteredHours.reduce((acc, cv) => acc + cv * hourlyRate, 0);
59+
return totalEarnings;
60+
} };
5261

5362
// eslint-disable-next-line no-unused-vars
5463
const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate);
64+
//two decimal
65+
console.log(`Maartje has earned: €${maartjesEarnings.toFixed(2)}`);
5566

56-
// add code to convert `earnings` to a string rounded to two decimals (euro cents)
57-
58-
console.log(`Maartje has earned €${'replace this string with the earnings rounded to euro cents'}`);
5967

6068
// Do not change or remove anything below this line
6169
module.exports = {

Week2/homework/map-filter.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
22

3+
4+
35
function doubleOddNumbers(numbers) {
4-
// Replace this comment and the next line with your code
5-
console.log(numbers);
6+
return numbers.filter(num => num % 2 !== 0).map(oddNum => oddNum * 2);
67
}
7-
88
const myNumbers = [1, 2, 3, 4];
99
console.log(doubleOddNumbers(myNumbers));
1010

Week2/test/map-filter.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ describe('map_filter', () => {
66
expect(result).toEqual([2, 6]);
77
});
88
});
9+

0 commit comments

Comments
 (0)