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

Skip to content

Commit 18b9b0e

Browse files
committed
finished homework Week 2
finished and fixed the issue with the package json
1 parent aa12a34 commit 18b9b0e

File tree

5 files changed

+1505
-1450
lines changed

5 files changed

+1505
-1450
lines changed

Week2/homework/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
<script src="./map-filter.js"></script>
11+
<script src="./maartjes-work.js"></script>
12+
<script src="./squirtle-sprites.js"></script>
13+
</body>
14+
</html>

Week2/homework/maartjes-work.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,28 @@ const maartjesTasks = monday.concat(tuesday);
4646
const maartjesHourlyRate = 20;
4747

4848
function computeEarnings(tasks, hourlyRate) {
49-
// Replace this comment and the next line with your code
50-
console.log(tasks, hourlyRate);
49+
let durations = tasks.map(item => {
50+
let duration = item.duration;
51+
return (duration / 60);
52+
}).filter(item => {
53+
if (item >= 2) {
54+
return item;
55+
}
56+
})
57+
console.log(durations);
58+
let money = durations.reduce((total, current) => {
59+
let number = (parseFloat(current) * hourlyRate);
60+
return total += number;
61+
}, 0);
62+
return money;
5163
}
5264

5365
// eslint-disable-next-line no-unused-vars
5466
const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate);
5567

5668
// add code to convert `earnings` to a string rounded to two decimals (euro cents)
5769

58-
console.log(`Maartje has earned €${'replace this string with the earnings rounded to euro cents'}`);
70+
console.log(`Maartje has earned €${earnings.toFixed(2)}`);
5971

6072
// Do not change or remove anything below this line
6173
module.exports = {

Week2/homework/map-filter.js

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

33
function doubleOddNumbers(numbers) {
4-
// Replace this comment and the next line with your code
5-
console.log(numbers);
4+
let doubleOddNumbers = numbers.filter((item) => {
5+
if (item % 2 !== 0) {
6+
return item;
7+
}
8+
}).map(num => {
9+
return num * 2;
10+
})
11+
return doubleOddNumbers;
612
}
713

814
const myNumbers = [1, 2, 3, 4];

Week2/homework/squirtle-sprites.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,22 @@ function fetchPokemonData() {
99
}
1010

1111
/* Code goes below */
12+
let body = document.querySelector("body");
13+
let div = document.createElement("div");
14+
body.appendChild(div);
15+
console.log(body);
16+
let pokemon = JSON.parse(fetchPokemonData());
17+
let pokemonSprites = Object.values(pokemon.sprites).filter(item => {
18+
if (item != "null") {
19+
return item;
20+
}
21+
});
22+
console.log(pokemonSprites);
23+
function appendSprites() {
24+
pokemonSprites.forEach(element => {
25+
let img = document.createElement("img");
26+
img.setAttribute("src", element);
27+
body.appendChild(img);
28+
});
29+
};
30+
appendSprites();

0 commit comments

Comments
 (0)