From 1720f6c0f429dd532b6132be0a5d154f27ef498d Mon Sep 17 00:00:00 2001 From: serotonine Date: Wed, 26 Nov 2025 19:32:22 +0100 Subject: [PATCH 01/12] Sprint1: exercice 1. --- Sprint-1/destructuring/exercise-1/exercise.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-1/destructuring/exercise-1/exercise.js b/Sprint-1/destructuring/exercise-1/exercise.js index 1ff2ac5c..90eb4795 100644 --- a/Sprint-1/destructuring/exercise-1/exercise.js +++ b/Sprint-1/destructuring/exercise-1/exercise.js @@ -6,7 +6,7 @@ const personOne = { // Update the parameter to this function to make it work. // Don't change anything else. -function introduceYourself(___________________________) { +function introduceYourself({name, age, favouriteFood}) { console.log( `Hello, my name is ${name}. I am ${age} years old and my favourite food is ${favouriteFood}.` ); From 4c005463810afc7c4c6eb672937406bab626390e Mon Sep 17 00:00:00 2001 From: serotonine Date: Wed, 26 Nov 2025 20:49:02 +0100 Subject: [PATCH 02/12] Sprint1: exercise-2. --- Sprint-1/destructuring/exercise-2/exercise.js | 23 ++++++++++++ Sprint-1/destructuring/exercise-2/readme.md | 37 ------------------- 2 files changed, 23 insertions(+), 37 deletions(-) delete mode 100644 Sprint-1/destructuring/exercise-2/readme.md diff --git a/Sprint-1/destructuring/exercise-2/exercise.js b/Sprint-1/destructuring/exercise-2/exercise.js index e11b75eb..34ec7891 100644 --- a/Sprint-1/destructuring/exercise-2/exercise.js +++ b/Sprint-1/destructuring/exercise-2/exercise.js @@ -70,3 +70,26 @@ let hogwarts = [ occupation: "Teacher", }, ]; + +let gryffindor = ""; +let teatcherDog = ""; +for (let witcher of hogwarts) { + const { + firstName: name, + lastName: surname, + house, + pet, + occupation, + } = witcher; + + const text = name + " " + surname + "\n"; + if (house === "Gryffindor") { + gryffindor += text; + if (pet && occupation === "Teacher") { + teatcherDog += text; + } + } +} + +console.log(`\nGryffindor Residents:\n${gryffindor}`); +console.log(`\nGryffindor Teacher who has pet:\n${teatcherDog}`); diff --git a/Sprint-1/destructuring/exercise-2/readme.md b/Sprint-1/destructuring/exercise-2/readme.md deleted file mode 100644 index 64b5ab1c..00000000 --- a/Sprint-1/destructuring/exercise-2/readme.md +++ /dev/null @@ -1,37 +0,0 @@ -# Exercise 2 - -In `exercise.js`, you have an array that contains a list of people who are at Hogwarts School of Witchcraft and Wizardry. - -For each character you have the following information: - -- First Name -- Last Name -- School House -- Pet -- Occupation - -## Task 1 - -- In `exercise.js` write a program that will take the `hogwarts` array as input and display the names of the people who belong to the Gryffindor house. -- Use object destructuring to extract the values you need out of each element in the array. - -### Expected result - -``` -Harry Potter -Ron Weasley -Hermione Granger -Minerva McGonagall -Albus Dumbledore -``` - -## Task 2 - -- In `exercise.js` write a program that will take the `hogwarts` array as input and display the names of teachers who have pets. -- Use object destructuring to extract the values you need out of each element in the array. - -### Expected result - -``` -Albus Dumbledore -``` From 09a45f5a2de352aaa106996831e0ca2a0f971548 Mon Sep 17 00:00:00 2001 From: serotonine Date: Wed, 26 Nov 2025 21:30:46 +0100 Subject: [PATCH 03/12] Sprint1: exercise-3. --- Sprint-1/destructuring/exercise-3/exercise.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sprint-1/destructuring/exercise-3/exercise.js b/Sprint-1/destructuring/exercise-3/exercise.js index b3a36f4e..3ba41c49 100644 --- a/Sprint-1/destructuring/exercise-3/exercise.js +++ b/Sprint-1/destructuring/exercise-3/exercise.js @@ -6,3 +6,13 @@ let order = [ { itemName: "Hot Coffee", quantity: 2, unitPricePence: 100 }, { itemName: "Hash Brown", quantity: 4, unitPricePence: 40 }, ]; +const setPrice = (pricePence) => (pricePence / 100).toFixed(2) +let total = 0; +console.log(`${("QTY").padEnd(7)}${"ITEM".padEnd( 20)}TOTAL`); +for (let item of order){ + const {itemName, quantity, unitPricePence} = item; + const sousTotal = (quantity * unitPricePence); + total += sousTotal; + console.log(`${(quantity+"").padEnd(7)}${itemName.padEnd(20)}${setPrice(sousTotal)}`); +} +console.log(`\n${("TOTAL").padEnd(26)}${setPrice(total)}`); From e904c54d88bcf91b9fe868c616a07d13dfa94069 Mon Sep 17 00:00:00 2001 From: serotonine Date: Fri, 28 Nov 2025 14:00:42 +0100 Subject: [PATCH 04/12] challenges: cowsay / solution 1. --- challenges/challenge-cowsay-two/solution1.js | 52 +++++++++++++------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/challenges/challenge-cowsay-two/solution1.js b/challenges/challenge-cowsay-two/solution1.js index a7f2416b..24dcca91 100644 --- a/challenges/challenge-cowsay-two/solution1.js +++ b/challenges/challenge-cowsay-two/solution1.js @@ -4,27 +4,43 @@ // https://nodejs.dev/learn/nodejs-accept-arguments-from-the-command-line // ================= -// 1. Accept arguments +function drawBubble(str, lg){ + if(!str){return} + let bubble = ""; + bubble += ` ${"–".repeat(lg + 2)} \n`; + bubble += `< ${str} >\n`; + bubble += ` ${"-".repeat(lg + 2)}`; + console.log(bubble); -// how will you accept arguments? - -// 2. Make supplies for our speech bubble - -let topLine = '_'; -let bottomLine = '-'; -let saying = ''; - -// 3. Make a cow that takes a string - -function cowsay(saying) { -// how will you make the speech bubble contain the text? - -// where will the cow picture go? +} -// how will you account for the parameter being empty? +function drawCow(talk, lg){ + const prefix = (" ").repeat(lg + 2 - Math.round(lg / 2)); + const stucks = [ + `${talk?"\\ ^——^":" ^——^"}\n`, + `${talk?" \\ (oo)\________":" (oo)\________"}\n`, + ` (__)\\ )\\/\\\n`, + ` ||----w |\n`, + ` || ||` + ].map((row)=> prefix + row); +console.log(stucks.join("")); } -//4. Pipe argument into cowsay function and return a cow +function cowsay() { + // Get console argument. + const talk = process.argv.at(2); + // If no argument. + if(!talk){ + console.log("No talk"); + return; + } + const lg = talk.length; + drawCow(false, lg); + setTimeout(()=>{ + drawBubble(talk,lg); + drawCow(true, lg); + }, 1000); +} -// how will you log this to the console? +cowsay(); From 5a131f56e57537a23c0b41c10f4d149313f94d28 Mon Sep 17 00:00:00 2001 From: serotonine Date: Fri, 28 Nov 2025 15:03:58 +0100 Subject: [PATCH 05/12] challenges: cowsay / solution 2. --- challenges/challenge-cowsay-two/solution2.js | 48 ++++++++++++++++---- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/challenges/challenge-cowsay-two/solution2.js b/challenges/challenge-cowsay-two/solution2.js index 8aca8572..ff7e9a12 100644 --- a/challenges/challenge-cowsay-two/solution2.js +++ b/challenges/challenge-cowsay-two/solution2.js @@ -1,18 +1,48 @@ +import readlineSync from 'readline-sync'; // ================= // Stripped down cowsayer CLI, -// no libraries or arguments -// https://nodejs.dev/learn/accept-input-from-the-command-line-in-nodejs +// no libraries +// https://nodejs.dev/learn/nodejs-accept-arguments-from-the-command-line // ================= -// 1. Make a command line interface. +function drawBubble(str, lg){ + if(!str){return} + let bubble = ""; + bubble += ` ${"–".repeat(lg + 2)} \n`; + bubble += `< ${str} >\n`; + bubble += ` ${"-".repeat(lg + 2)}`; + console.log(bubble); -// 2. Make supplies for our speech bubble +} + +function drawCow(talk, lg=0){ + const prefix = (" ").repeat(lg + 2 - Math.round(lg / 2)); + const stucks = [ + `${talk?"\\ ^——^":" ^——^"}\n`, + `${talk?" \\ (oo)\________":" (oo)\________"}\n`, + ` (__)\\ )\\/\\\n`, + ` ||----w |\n`, + ` || ||` + ].map((row)=> prefix + row); +console.log(stucks.join("")); -// 3. Make a cow that takes a string +} -const cow = (saying) => { - // how did you make the cow before? +function cowsay() { + drawCow(false); + // Get console argument. + const talk = readlineSync.question('Wazz up Miss Cow? '); + // If no argument. + if(!talk){ + console.log("Miss Cow is not very talkative..."); + return; + } + const lg = talk.length; + + setTimeout(()=>{ + drawBubble(talk,lg); + drawCow(true, lg); + }, 1000); } -// 4. Use readline to get a string from the terminal -// (with a prompt so it's clearer what we want) \ No newline at end of file +cowsay(); From c04e00fc80ce36e31d2cfc6077dba71645a0081f Mon Sep 17 00:00:00 2001 From: serotonine Date: Fri, 5 Dec 2025 15:07:11 +0100 Subject: [PATCH 06/12] Clean local --- .gitignore | 3 +- Sprint-1/destructuring/exercise-2/readme.md | 37 ++++++++++++++++++++ challenges/challenge-cowsay-two/package.json | 27 ++++++++++++++ package-lock.json | 4 +++ 4 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 Sprint-1/destructuring/exercise-2/readme.md create mode 100644 challenges/challenge-cowsay-two/package.json diff --git a/.gitignore b/.gitignore index c4d4e3a1..7f134d93 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules **/node_modules .DS_Store -**/.DS_Store \ No newline at end of file +**/.DS_Store +package-lock.json \ No newline at end of file diff --git a/Sprint-1/destructuring/exercise-2/readme.md b/Sprint-1/destructuring/exercise-2/readme.md new file mode 100644 index 00000000..64b5ab1c --- /dev/null +++ b/Sprint-1/destructuring/exercise-2/readme.md @@ -0,0 +1,37 @@ +# Exercise 2 + +In `exercise.js`, you have an array that contains a list of people who are at Hogwarts School of Witchcraft and Wizardry. + +For each character you have the following information: + +- First Name +- Last Name +- School House +- Pet +- Occupation + +## Task 1 + +- In `exercise.js` write a program that will take the `hogwarts` array as input and display the names of the people who belong to the Gryffindor house. +- Use object destructuring to extract the values you need out of each element in the array. + +### Expected result + +``` +Harry Potter +Ron Weasley +Hermione Granger +Minerva McGonagall +Albus Dumbledore +``` + +## Task 2 + +- In `exercise.js` write a program that will take the `hogwarts` array as input and display the names of teachers who have pets. +- Use object destructuring to extract the values you need out of each element in the array. + +### Expected result + +``` +Albus Dumbledore +``` diff --git a/challenges/challenge-cowsay-two/package.json b/challenges/challenge-cowsay-two/package.json new file mode 100644 index 00000000..65b9ee96 --- /dev/null +++ b/challenges/challenge-cowsay-two/package.json @@ -0,0 +1,27 @@ +{ + "name": "challenges", + "version": "1.0.0", + "description": "Javascript and node.js challenges.", + "keywords": [ + "javascript", + "HYF" + ], + "homepage": "https://github.com/serotonine/HYF-Module-Data-Flows#readme", + "bugs": { + "url": "https://github.com/serotonine/HYF-Module-Data-Flows/issues" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/serotonine/HYF-Module-Data-Flows.git" + }, + "license": "ISC", + "author": "Serotonine", + "type": "module", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "readline-sync": "^1.4.10" + } +} diff --git a/package-lock.json b/package-lock.json index 52884e65..4beb4ac5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -53,6 +53,7 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.21.4.tgz", "integrity": "sha512-qt/YV149Jman/6AfmlxJ04LMIu8bMoyl3RB91yTFrxQmgbrSvQMy7cI8Q62FHx1t8wJ8B5fu0UDoLwHAhUo1QA==", "dev": true, + "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.21.4", @@ -1264,6 +1265,7 @@ "url": "https://tidelift.com/funding/github/npm/browserslist" } ], + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001449", "electron-to-chromium": "^1.4.284", @@ -3488,6 +3490,7 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.21.4.tgz", "integrity": "sha512-qt/YV149Jman/6AfmlxJ04LMIu8bMoyl3RB91yTFrxQmgbrSvQMy7cI8Q62FHx1t8wJ8B5fu0UDoLwHAhUo1QA==", "dev": true, + "peer": true, "requires": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.21.4", @@ -4442,6 +4445,7 @@ "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.5.tgz", "integrity": "sha512-tUkiguQGW7S3IhB7N+c2MV/HZPSCPAAiYBZXLsBhFB/PCy6ZKKsZrmBayHV9fdGV/ARIfJ14NkxKzRDjvp7L6w==", "dev": true, + "peer": true, "requires": { "caniuse-lite": "^1.0.30001449", "electron-to-chromium": "^1.4.284", From d4caf57bfc7b14f10ad1d68b1d4818cb175b5520 Mon Sep 17 00:00:00 2001 From: serotonine Date: Mon, 8 Dec 2025 14:13:04 +0100 Subject: [PATCH 07/12] challenges: weather-app. --- .../challenge-weather-app/assets/globals.css | 3 +- .../challenge-weather-app/assets/styles.css | 14 +- challenges/challenge-weather-app/index.html | 8 +- .../challenge-weather-app/js/includes/dom.js | 43 + .../js/includes/httpRequest.js | 42 + challenges/challenge-weather-app/js/index.js | 82 + .../challenge-weather-app/package-lock.json | 3 - package-lock.json | 2608 +---------------- package.json | 3 + 9 files changed, 199 insertions(+), 2607 deletions(-) create mode 100644 challenges/challenge-weather-app/js/includes/dom.js create mode 100644 challenges/challenge-weather-app/js/includes/httpRequest.js create mode 100644 challenges/challenge-weather-app/js/index.js delete mode 100644 challenges/challenge-weather-app/package-lock.json diff --git a/challenges/challenge-weather-app/assets/globals.css b/challenges/challenge-weather-app/assets/globals.css index c9742ea5..83ae8249 100644 --- a/challenges/challenge-weather-app/assets/globals.css +++ b/challenges/challenge-weather-app/assets/globals.css @@ -12,10 +12,11 @@ :root { --thumb-w: 80px; - --thumb-h: 45px; + --thumb-h: 80px; --thumbs-px: 10px; --thumbs-py: 10px; --thumbs-h: calc(var(--thumb-h) + (var(--thumbs-py) * 2)); + --color-main:oklab(30.993% -0.01087 -0.01628); } html, diff --git a/challenges/challenge-weather-app/assets/styles.css b/challenges/challenge-weather-app/assets/styles.css index 9046ba1b..248eb903 100644 --- a/challenges/challenge-weather-app/assets/styles.css +++ b/challenges/challenge-weather-app/assets/styles.css @@ -1,7 +1,7 @@ .content { + background-color: var(--color-main); display: grid; grid-template-rows: auto 1fr auto auto auto; - height: 100vh; overflow: hidden; } @@ -35,15 +35,14 @@ display: grid; justify-content: center; align-content: center; - overflow: hidden; position: relative; margin: 20px 0; } .photo::before { - content: "loading"; - + content: "loading..."; + color:white; display: grid; justify-content: center; align-content: center; @@ -58,6 +57,9 @@ text-transform: uppercase; letter-spacing: 3px; } +.photo.init::before{ + content: "Please search a location"; +} .photo__dummy, .photo > img { @@ -220,11 +222,11 @@ /*----------------------------------------------------------------------------*/ @media (min-width: 768px) { .title { - font-weight: 100; + font-weight: 400; } .thumbs { - justify-content: center; + /* justify-content: center; */ } .controls { diff --git a/challenges/challenge-weather-app/index.html b/challenges/challenge-weather-app/index.html index b1add346..4ea2a778 100644 --- a/challenges/challenge-weather-app/index.html +++ b/challenges/challenge-weather-app/index.html @@ -21,7 +21,9 @@

-
+
+ +

@@ -32,7 +34,8 @@

-
+
+