From 5344a622ddd2ce6e722bca04e61bf64851ed6a57 Mon Sep 17 00:00:00 2001
From: diana-dodan <148563980+diana-dodan@users.noreply.github.com>
Date: Fri, 19 Jan 2024 00:19:16 +0100
Subject: [PATCH 1/6] Update maartjes-work.js
---
Week2/homework/maartjes-work.js | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/Week2/homework/maartjes-work.js b/Week2/homework/maartjes-work.js
index 49772eb44..a5714454e 100644
--- a/Week2/homework/maartjes-work.js
+++ b/Week2/homework/maartjes-work.js
@@ -46,8 +46,30 @@ const maartjesTasks = monday.concat(tuesday);
const maartjesHourlyRate = 20;
function computeEarnings(tasks, hourlyRate) {
- // Replace this comment and the next line with your code
- console.log(tasks, hourlyRate);
+ //Map the tasks to durations in hours.
+ const tasksDurationInHours = tasks.map(task => {
+ return {
+ name: task.name,
+ duration: task.duration / 60,
+ };
+ });
+
+
+ //Filter out everything that took less than two hours (i.e., remove from the collection)
+ const filteredTask = tasksDurationInHours.filter(task => {
+ if (task.duration < 2) {
+ return false;
+ } else {
+ return true;
+ }
+ });
+
+ //Multiply the each duration by a per-hour rate for billing (use €20/hour) and sum it all up.
+ const priceArray = filteredTask.map(task => task.duration * 20);
+
+ const totalPrice = priceArray.reduce((a, b) => a + b, 0);
+
+ return Math.round(totalPrice * 100) / 100;
}
// eslint-disable-next-line no-unused-vars
@@ -55,7 +77,7 @@ const earnings = computeEarnings(maartjesTasks, maartjesHourlyRate);
// 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 = {
@@ -63,3 +85,4 @@ module.exports = {
maartjesHourlyRate,
computeEarnings,
};
+
From 3ab643df870bcabe2e55304cd2c7068cc5a8d4bc Mon Sep 17 00:00:00 2001
From: diana-dodan <148563980+diana-dodan@users.noreply.github.com>
Date: Fri, 19 Jan 2024 00:19:40 +0100
Subject: [PATCH 2/6] Update map-filter.js
---
Week2/homework/map-filter.js | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/Week2/homework/map-filter.js b/Week2/homework/map-filter.js
index c8e8a88c1..8aad82847 100644
--- a/Week2/homework/map-filter.js
+++ b/Week2/homework/map-filter.js
@@ -1,12 +1,22 @@
'use strict';
-function doubleOddNumbers(numbers) {
- // Replace this comment and the next line with your code
- console.log(numbers);
-}
+function throwAway(numbers) {
+ return numbers.filter(number => {
+ if (number % 2 === 0) {
+ return false;
+ }
+ return number;
+ });
+}
const myNumbers = [1, 2, 3, 4];
-console.log(doubleOddNumbers(myNumbers));
+console.log(throwAway(myNumbers));
+
+function doubleOddNumbers(numbers) {
+ return numbers.map(number => number * 2);
+}
+const newNumbers = throwAway(myNumbers);
+console.log(doubleOddNumbers(newNumbers));
// Do not change or remove anything below this line
module.exports = {
From e73825092f5822ead674ade8c3e04c3aea365dea Mon Sep 17 00:00:00 2001
From: diana-dodan <148563980+diana-dodan@users.noreply.github.com>
Date: Fri, 19 Jan 2024 00:21:50 +0100
Subject: [PATCH 3/6] Create index.html
---
Week2/homework/index.html | 11 +++++++++++
1 file changed, 11 insertions(+)
create mode 100644 Week2/homework/index.html
diff --git a/Week2/homework/index.html b/Week2/homework/index.html
new file mode 100644
index 000000000..a2d287ea2
--- /dev/null
+++ b/Week2/homework/index.html
@@ -0,0 +1,11 @@
+
+
+
+
+
+ Document
+
+
+
+
+
From 319a4845ec149e4811bf057ab21a2c8381dca588 Mon Sep 17 00:00:00 2001
From: diana-dodan <148563980+diana-dodan@users.noreply.github.com>
Date: Fri, 19 Jan 2024 00:22:33 +0100
Subject: [PATCH 4/6] Update squirtle-sprites.js
---
Week2/homework/squirtle-sprites.js | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/Week2/homework/squirtle-sprites.js b/Week2/homework/squirtle-sprites.js
index b6b6e2920..91f435ecc 100644
--- a/Week2/homework/squirtle-sprites.js
+++ b/Week2/homework/squirtle-sprites.js
@@ -7,5 +7,10 @@
function fetchPokemonData() {
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}';
}
-
/* Code goes below */
+
+fetchPokemonData();
+const json = fetchPokemonData();
+const newString = JSON.parse(json);
+
+console.log(newString);
From 96518b01eb6ce183accf4a0a80134c7dd5a73b8a Mon Sep 17 00:00:00 2001
From: diana-dodan <148563980+diana-dodan@users.noreply.github.com>
Date: Sat, 20 Jan 2024 23:39:28 +0100
Subject: [PATCH 5/6] Update squirtle-sprites.js
---
Week2/homework/squirtle-sprites.js | 33 +++++++++++++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/Week2/homework/squirtle-sprites.js b/Week2/homework/squirtle-sprites.js
index 91f435ecc..394b59624 100644
--- a/Week2/homework/squirtle-sprites.js
+++ b/Week2/homework/squirtle-sprites.js
@@ -7,10 +7,41 @@
function fetchPokemonData() {
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}';
}
-/* Code goes below */
fetchPokemonData();
const json = fetchPokemonData();
const newString = JSON.parse(json);
console.log(newString);
+
+function onlyTheLinks(sprites) {
+ const values = Object.values(sprites);
+ return values.filter(link => {
+ if (link === null) {
+ return false;
+ }
+
+ return true;
+ });
+}
+const links = onlyTheLinks(newString.sprites);
+console.log(links);
+
+/**
+ * [
+ 'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/7.png',
+ 'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/shiny/7.png',
+ 'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/7.png',
+ 'https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/7.png'
+]
+ */
+links.map(link => {
+ console.log(link);
+ // create img element
+ let img = document.createElement('img');
+ // set src attribute using link
+ img.setAttribute('src', link);
+ // append to html body
+ document.getElementById('sprites').appendChild(img);
+});
+
From aa6f5c111449806b2dff72839e8118299030e6f6 Mon Sep 17 00:00:00 2001
From: diana-dodan <148563980+diana-dodan@users.noreply.github.com>
Date: Sat, 20 Jan 2024 23:40:55 +0100
Subject: [PATCH 6/6] Update index.html
---
Week2/homework/index.html | 1 +
1 file changed, 1 insertion(+)
diff --git a/Week2/homework/index.html b/Week2/homework/index.html
index a2d287ea2..305ad20b7 100644
--- a/Week2/homework/index.html
+++ b/Week2/homework/index.html
@@ -6,6 +6,7 @@
Document
+