Skip to content

Commit f37044d

Browse files
Merge pull request #2 from outintotheblue/secondweek
Secondweek
2 parents e7da7cd + 085ce28 commit f37044d

6 files changed

Lines changed: 38 additions & 16 deletions

File tree

‎Week2/homework/maartjes-work.js‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,26 +46,23 @@ const maartjesTasks = monday.concat(tuesday);
4646
const maartjesHourlyRate = 20;
4747

4848
function computeEarnings(tasks, hourlyRate) {
49-
const inHoursArr = tasks.map(hours => task.duration / 60).filter(hours => hours <= 2);
49+
const inHoursArr = tasks.map(task => task.duration / 60).filter(hours => hours <= 2);
5050
const maartjesPayArr = inHoursArr.map(hours => hours * maartjesHourlyRate);
5151
const totalPay = maartjesPayArr.reduce((sum, amount) => sum + amount);
52-
53-
console.log(totalPay);
54-
return totalPay;
55-
56-
52+
const toEuro = totalPay.toFixed(2);
53+
return toEuro;
5754
}
5855

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

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

64-
//console.log(`Maartje has earned €${'replace this string with the earnings rounded to euro cents'}`);
61+
console.log(`Maartje has earned €${earnings}`);
6562

6663
// Do not change or remove anything below this line
67-
//module.exports = {
68-
// maartjesTasks,
69-
// maartjesHourlyRate,
70-
// computeEarnings,
71-
//};
64+
module.exports = {
65+
maartjesTasks,
66+
maartjesHourlyRate,
67+
computeEarnings,
68+
};

‎Week2/homework/map-filter.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,9 @@ function doubleOddNumbers(numbers) {
2323

2424
const myNumbers = [1, 2, 3, 4];
2525
console.log(doubleOddNumbers(myNumbers));
26+
27+
// Do not change or remove anything below this line
28+
module.exports = {
29+
myNumbers,
30+
doubleOddNumbers,
31+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
html {
2+
background-color: blanchedalmond;
3+
}
4+
5+
img {
6+
width: 250px;
7+
}

‎Week2/homework/squirtle-sprites.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33

44
<head>
5-
5+
<link rel="stylesheet" href="squirtle-sprites.css">
66
</head>
77

88

‎Week2/homework/squirtle-sprites.js‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,18 @@
55
(simulates calling a server to retrieve data)
66
*/
77
function fetchPokemonData() {
8-
return '{"abilities":[{"ability":{"name":"rain-dish","url":"https://pokeapi.co/api/v2/ability/44/"},"is_hidden":true,"slot":3},{"ability":{"name":"torrent","url":"https://pokeapi.co/api/v2/ability/67/"},"is_hidden":false,"slot":1}],"base_experience":63,"forms":[{"name":"squirtle","url":"https://pokeapi.co/api/v2/pokemon-form/7/"}],"height":5,"held_items":[],"id":7,"is_default":true,"location_area_encounters":"https://pokeapi.co/api/v2/pokemon/7/encounters","name":"squirtle","order":10,"species":{"name":"squirtle","url":"https://pokeapi.co/api/v2/pokemon-species/7/"},"sprites":{"back_default":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/7.png","back_female":null,"back_shiny":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/shiny/7.png","back_shiny_female":null,"front_default":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/7.png","front_female":null,"front_shiny":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/7.png","front_shiny_female":null},"stats":[{"base_stat":43,"effort":0,"stat":{"name":"speed","url":"https://pokeapi.co/api/v2/stat/6/"}},{"base_stat":64,"effort":0,"stat":{"name":"special-defense","url":"https://pokeapi.co/api/v2/stat/5/"}},{"base_stat":50,"effort":0,"stat":{"name":"special-attack","url":"https://pokeapi.co/api/v2/stat/4/"}},{"base_stat":65,"effort":1,"stat":{"name":"defense","url":"https://pokeapi.co/api/v2/stat/3/"}},{"base_stat":48,"effort":0,"stat":{"name":"attack","url":"https://pokeapi.co/api/v2/stat/2/"}},{"base_stat":44,"effort":0,"stat":{"name":"hp","url":"https://pokeapi.co/api/v2/stat/1/"}}],"types":[{"slot":1,"type":{"name":"water","url":"https://pokeapi.co/api/v2/type/11/"}}],"weight":90}';
9-
}
8+
const pokeInfo =
9+
'{"abilities":[{"ability":{"name":"rain-dish","url":"https://pokeapi.co/api/v2/ability/44/"},"is_hidden":true,"slot":3},{"ability":{"name":"torrent","url":"https://pokeapi.co/api/v2/ability/67/"},"is_hidden":false,"slot":1}],"base_experience":63,"forms":[{"name":"squirtle","url":"https://pokeapi.co/api/v2/pokemon-form/7/"}],"height":5,"held_items":[],"id":7,"is_default":true,"location_area_encounters":"https://pokeapi.co/api/v2/pokemon/7/encounters","name":"squirtle","order":10,"species":{"name":"squirtle","url":"https://pokeapi.co/api/v2/pokemon-species/7/"},"sprites":{"back_default":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/7.png","back_female":null,"back_shiny":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/shiny/7.png","back_shiny_female":null,"front_default":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/7.png","front_female":null,"front_shiny":"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/7.png","front_shiny_female":null},"stats":[{"base_stat":43,"effort":0,"stat":{"name":"speed","url":"https://pokeapi.co/api/v2/stat/6/"}},{"base_stat":64,"effort":0,"stat":{"name":"special-defense","url":"https://pokeapi.co/api/v2/stat/5/"}},{"base_stat":50,"effort":0,"stat":{"name":"special-attack","url":"https://pokeapi.co/api/v2/stat/4/"}},{"base_stat":65,"effort":1,"stat":{"name":"defense","url":"https://pokeapi.co/api/v2/stat/3/"}},{"base_stat":48,"effort":0,"stat":{"name":"attack","url":"https://pokeapi.co/api/v2/stat/2/"}},{"base_stat":44,"effort":0,"stat":{"name":"hp","url":"https://pokeapi.co/api/v2/stat/1/"}}],"types":[{"slot":1,"type":{"name":"water","url":"https://pokeapi.co/api/v2/type/11/"}}],"weight":90}';
10+
1011

11-
/* Code goes below */
12+
/* Code goes below */
13+
14+
const pokeJSON = JSON.parse(pokeInfo);
15+
console.log(pokeJSON);
16+
for (const i in pokeJSON.sprites) {
17+
const pokeImg = document.createElement('img');
18+
pokeImg.src = pokeJSON.sprites[i];
19+
document.body.appendChild(pokeImg);
20+
}
21+
}
1222
fetchPokemonData();

‎Week2/homework/wesBrosArray.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//Array.prototype.filter()
2+
//1. Filter the list of inventors for those who were born in the 1500's

0 commit comments

Comments
 (0)