Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Week2/homework/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script src="squirtle-sprites.js"></script>
</body>
</html>
16 changes: 9 additions & 7 deletions Week2/homework/maartjes-work.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,22 @@ const tuesday = [
},
];

const maartjesTasks = monday.concat(tuesday);
const maartjesTasks = [...monday, ...tuesday];
const maartjesHourlyRate = 20;

function computeEarnings(tasks, hourlyRate) {
// Replace this comment and the next line with your code
console.log(tasks, hourlyRate);
return tasks
.map(task => task.duration / 60)
.filter(duration => duration >= 2)
.map(duration => duration * hourlyRate)
.reduce((total, earning) => total + earning, 0);
}
console.log(computeEarnings(maartjesTasks, maartjesHourlyRate));

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

const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate).toFixed(2);
// 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 €${earnings}`);

// Do not change or remove anything below this line
module.exports = {
Expand Down
6 changes: 2 additions & 4 deletions Week2/homework/map-filter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict';

function doubleOddNumbers(numbers) {
// Replace this comment and the next line with your code
console.log(numbers);
}
const doubleOddNumbers = numbers =>
numbers.filter(number => number % 2 !== 0).map(oddNumber => oddNumber * 2);

const myNumbers = [1, 2, 3, 4];
console.log(doubleOddNumbers(myNumbers));
Expand Down
31 changes: 31 additions & 0 deletions Week2/homework/squirtle-sprites.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,34 @@ function fetchPokemonData() {
}

/* Code goes below */

const displaySprites = () => {
const data = JSON.parse(fetchPokemonData());
const { sprites } = data;
const section = document.createElement('section');

for (const key in sprites) {
const div = document.createElement('div');
const img = document.createElement('img');
if (sprites[key]) {
img.src = sprites[key];
section.appendChild(div);
div.appendChild(img);
}
}
// const spritesKeys = Object.keys(sprites);
// console.log(spritesKeys);
// spritesKeys.forEach(key => {
// const div = document.createElement('div');
// const img = document.createElement('img');
// if (sprites[key]) {
// img.src = sprites[key];
// section.appendChild(div);
// div.appendChild(img);
// }
// });

document.body.appendChild(section);
};

displaySprites();