Skip to content

Commit d6f055d

Browse files
committed
added solutions
1 parent 34150d8 commit d6f055d

3 files changed

Lines changed: 30 additions & 4 deletions

File tree

Week2/homework/maartjes-work.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,22 @@ const maartjesHourlyRate = 20;
4747

4848
function computeEarnings(tasks, hourlyRate) {
4949
// Replace this comment and the next line with your code
50-
console.log(tasks, hourlyRate);
50+
const taskRate = tasks
51+
.map(task => task.duration / 60) // map duration in hours
52+
.filter(duration => duration >= 2) //remove the duration, that is < 2 hours
53+
.map(duration => duration * hourlyRate) //multiply each duration per hour (rate =20)
54+
.reduce((total, value) => total + value) // Total sum all
55+
return taskRate;
56+
5157
}
5258

59+
5360
// eslint-disable-next-line no-unused-vars
54-
const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate);
61+
const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate).toFixed(2);
5562

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

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

6067
// Do not change or remove anything below this line
6168
module.exports = {

Week2/homework/map-filter.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22

33
function doubleOddNumbers(numbers) {
44
// Replace this comment and the next line with your code
5-
console.log(numbers);
5+
const newNumbers = numbers.filter(oddNum => oddNum % 2 !== 0);
6+
7+
numbers = newNumbers.map(double => double * 2);
8+
//console.log(numbers);
9+
return numbers;
610
}
711

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

Week2/homework/squirtle-sprites.js

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

1111
/* Code goes below */
12+
//console.log(fetchPokemonData());
13+
14+
15+
let pokemonData = JSON.parse(fetchPokemonData());
16+
console.log(pokemonData);
17+
18+
let spritesLists = Object.values(pokemonData.sprites);
19+
let imagesLists = spritesLists.filter(i => i != null);
20+
21+
const showImages = imagesLists.map(image => {
22+
pokemonImage = document.createElement('img');
23+
pokemonImage.src = image;
24+
pokemonImage.height = '200';
25+
document.body.appendChild(pokemonImage);
26+
});

0 commit comments

Comments
 (0)