From d00d3a63e582982a0714a28fdda72a3702aa040f Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 20 Oct 2025 13:13:56 +0200 Subject: [PATCH 001/113] added index.html from week 1 --- .../intro-to-frontend/week1/index.html | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 courses/foundation/intro-to-frontend/week1/index.html diff --git a/courses/foundation/intro-to-frontend/week1/index.html b/courses/foundation/intro-to-frontend/week1/index.html new file mode 100644 index 000000000..1d4a49bc9 --- /dev/null +++ b/courses/foundation/intro-to-frontend/week1/index.html @@ -0,0 +1,94 @@ + + + + + + + + PAYMENT <span>FORM</span> + + + + + + +
+
+

SOME HEADER

+

Some optional stuff.

+
+
+

Order Summary

+
+
TOTAL
+
$333 / month
+
+
+
+
TOTAL
+
$100
+
+
+
+ +
+
+

Payment Method

+
+ + +
+
+ + +
+

Card Info

+
+
+ + + +
+
+
+ + +
+ +
+ + + +
+
+
+
+ + +

Need Help?

+
+ + + + \ No newline at end of file From 80783a0e66faf6630e76a2a787a5886d27e82278 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 20 Oct 2025 13:14:23 +0200 Subject: [PATCH 002/113] added styles.css from week 1 --- .../intro-to-frontend/week1/styles.css | 238 ++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100644 courses/foundation/intro-to-frontend/week1/styles.css diff --git a/courses/foundation/intro-to-frontend/week1/styles.css b/courses/foundation/intro-to-frontend/week1/styles.css new file mode 100644 index 000000000..e3a2e8990 --- /dev/null +++ b/courses/foundation/intro-to-frontend/week1/styles.css @@ -0,0 +1,238 @@ +@import url('https://fonts.google.com/specimen/Montserrat'); + +html { + background-color: #2310164D; +} + +body { + align-items: center; + justify-content: center; + margin: auto; + width: 100vw; + min-width: 300px; + min-height: 50px; + font-family: Arial, Helvetica, sans-serif; +} + +header { + min-height: 50px; + margin: 0 auto; + min-width: 300px; + max-width: 800px; +} + +a { + text-decoration: none; +} + +.header-text { + font-family: Montserrat; + text-align: center; + margin: 0 auto; + color: #ffffff; + justify-content: center; + padding: 10px; +} + +.header-text h1 { + font-size: 30px; + margin: 0 auto; +} + +.header-text p { + font-size: 20px; + margin: 0 auto; +} + +.order-summary { + margin: 0 auto; + text-align: center; + background: linear-gradient(90deg, #FD7B46, #FE4E9B); + max-width: 800px; + padding: 15px 0 15px 0; +} + +.order-summary h1 { + font-size: 24px; + color: white; +} + +.order-total-top { + width: 87.7%; + color: white; + display: flex; + justify-content: space-between; + margin: 7px auto; + font-weight: 400; +} + +.horizontal-line { + width: 87.7%; + height: 1px; + background: #fff; + margin: 0 auto; +} + +.order-total-bottom { + width: 87.7%; + color: white; + display: flex; + justify-content: space-between; + margin: 7px auto; + font-weight: 700; +} + +form { + max-width: 800px; + margin: 0 auto; + background-color: #ffffff; +} + +.card-info { + background-color: #ffffff; + width: 87.7%; + max-width: 800px; + margin: 0 auto; +} + +.payment-method { + background-color: #ffffff; + width: 87.7%; + padding-top: 10px; + padding-bottom: 10px; + margin: 0 auto; +} + +h2 { + text-align: center; +} + +input[type='radio'] { + appearance:none; +} + +.payment-method-selectors { + display: flex; + gap: 20px; +} + +.payment-method-selectors label { + display: flex; + flex: 1; +} + +.card { + display: flex; + flex-direction: column; + height: 110px; + min-width: 120px; + max-width: 300px; + flex: 1; + font-family: Montserrat; + font-style: bold; + filter: drop-shadow(8px 8px 20px #0000004D); + background-color: #ffffff; + margin: auto; + border-radius: 10px; + justify-content: center; + align-items: center; + font-size: 12px; + font-weight: 700; +} + +.selected { + border: 4px solid #FE4E9B; + box-sizing: border-box; +} + +.paypal-logo { + width: 22px; + filter: grayscale(100%); + margin-bottom: 10px; +} + +.card-logos { + width: 100px; + margin-bottom: 10px; +} + +.exp-and-cvv { + display: flex; + flex-direction: row; + margin: 0 auto; + justify-content: space-between; +} + +label { + font-family: Montserrat; + font-weight: 600; + font-size: 16px; + color: #939393; + text-align: center; + display: block; + margin-bottom: 6px; +} + +.exp-and-cvv-inputs { + width: 43.3%; + position: relative; +} + +.all-payment-info { + display: flex; + flex-direction: column; + width: 100%; + gap: 20px; +} + +.input-bar { + width: 100%; + height: 24px; + border: 1px solid #939393; + background-color: #F3F1F2; + border-radius: 2px; + font-size: 16px; + text-align: center; + margin: 0 auto 20px auto; + display: block; + box-sizing: border-box; +} + +.card-info-container { + width: 100%; + position: relative +} + +.info-icon { + position: absolute; + width: 20px; + right: 2px; + top: 27.5px; +} + +.buy-now { + width: 260px; + height: 68px; + border-radius: 68px; + display: block; + margin: 0 auto; + margin-top: 20px; + background: linear-gradient(90deg, #FD7B46, #FE4E9B); + font-family: Montserrat; + font-weight: 700; + font-size: 24px; + border: 0; + color: #ffffff; +} + +.help-button { + font-weight: 700; + font-size: 18px; + text-align: center; + background: linear-gradient(90deg, #FD7B46, #FE4E9B); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + background-clip: text; + padding-top: 24px; + padding-bottom: 40px; +} \ No newline at end of file From 38443d68f34dec1ba6084b813b70876f114fcb59 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 20 Oct 2025 13:14:52 +0200 Subject: [PATCH 003/113] added source.js from week 1 --- .../foundation/intro-to-frontend/week1/source.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 courses/foundation/intro-to-frontend/week1/source.js diff --git a/courses/foundation/intro-to-frontend/week1/source.js b/courses/foundation/intro-to-frontend/week1/source.js new file mode 100644 index 000000000..060e62d99 --- /dev/null +++ b/courses/foundation/intro-to-frontend/week1/source.js @@ -0,0 +1,15 @@ +const paymentTypes = document.querySelector('.payment-method-selectors'); +const cardPaymentSelector = paymentTypes.querySelector('#card-payment-selector'); +const paypalPaymentSelector = paymentTypes.querySelector('#paypal-payment-selector'); +const cardPaymentCard = document.querySelector('.card-payment-card'); +const paypalPaymentCard = document.querySelector('.paypal-payment-card'); + +cardPaymentSelector.addEventListener ('click', () => highlight(cardPaymentCard)); +paypalPaymentSelector.addEventListener ('click', () => highlight(paypalPaymentCard)); + +function highlight(target) { + console.log('click') + paypalPaymentCard.classList.remove('selected') + cardPaymentCard.classList.remove('selected') + target.classList.add('selected') +} \ No newline at end of file From 131b6580fdf1f98d3fe7a24e771facc11d14f33c Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 20 Oct 2025 13:26:08 +0200 Subject: [PATCH 004/113] added apples.txt --- courses/foundation/git/week1/apples-file.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 courses/foundation/git/week1/apples-file.txt diff --git a/courses/foundation/git/week1/apples-file.txt b/courses/foundation/git/week1/apples-file.txt new file mode 100644 index 000000000..c39067204 --- /dev/null +++ b/courses/foundation/git/week1/apples-file.txt @@ -0,0 +1 @@ +Apples \ No newline at end of file From 896bd8eed90b307780b2f0b8caea76d0e414990f Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 20 Oct 2025 13:27:27 +0200 Subject: [PATCH 005/113] added bananas-file.txt and oranges-file.txt --- courses/foundation/git/week1/bananas-file.txt | 1 + courses/foundation/git/week1/oranges-file.txt | 1 + 2 files changed, 2 insertions(+) create mode 100644 courses/foundation/git/week1/bananas-file.txt create mode 100644 courses/foundation/git/week1/oranges-file.txt diff --git a/courses/foundation/git/week1/bananas-file.txt b/courses/foundation/git/week1/bananas-file.txt new file mode 100644 index 000000000..76f82cb69 --- /dev/null +++ b/courses/foundation/git/week1/bananas-file.txt @@ -0,0 +1 @@ +Bananas \ No newline at end of file diff --git a/courses/foundation/git/week1/oranges-file.txt b/courses/foundation/git/week1/oranges-file.txt new file mode 100644 index 000000000..73a8088e9 --- /dev/null +++ b/courses/foundation/git/week1/oranges-file.txt @@ -0,0 +1 @@ +Oranges \ No newline at end of file From 9918639476d2bfed3faa79204455f69997d71333 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 20 Oct 2025 13:28:30 +0200 Subject: [PATCH 006/113] updated text of apples-file.txt --- courses/foundation/git/week1/apples-file.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/courses/foundation/git/week1/apples-file.txt b/courses/foundation/git/week1/apples-file.txt index c39067204..3534909e6 100644 --- a/courses/foundation/git/week1/apples-file.txt +++ b/courses/foundation/git/week1/apples-file.txt @@ -1 +1 @@ -Apples \ No newline at end of file +Apples, apples, so many apples! \ No newline at end of file From e426e70393b523f8804d27edbe589ae7f7199407 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 20 Oct 2025 13:31:43 +0200 Subject: [PATCH 007/113] moved fruit-related txt files into session-playground --- .../foundation/git/week1/{ => session-playground}/apples-file.txt | 0 .../git/week1/{ => session-playground}/bananas-file.txt | 0 .../git/week1/{ => session-playground}/oranges-file.txt | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename courses/foundation/git/week1/{ => session-playground}/apples-file.txt (100%) rename courses/foundation/git/week1/{ => session-playground}/bananas-file.txt (100%) rename courses/foundation/git/week1/{ => session-playground}/oranges-file.txt (100%) diff --git a/courses/foundation/git/week1/apples-file.txt b/courses/foundation/git/week1/session-playground/apples-file.txt similarity index 100% rename from courses/foundation/git/week1/apples-file.txt rename to courses/foundation/git/week1/session-playground/apples-file.txt diff --git a/courses/foundation/git/week1/bananas-file.txt b/courses/foundation/git/week1/session-playground/bananas-file.txt similarity index 100% rename from courses/foundation/git/week1/bananas-file.txt rename to courses/foundation/git/week1/session-playground/bananas-file.txt diff --git a/courses/foundation/git/week1/oranges-file.txt b/courses/foundation/git/week1/session-playground/oranges-file.txt similarity index 100% rename from courses/foundation/git/week1/oranges-file.txt rename to courses/foundation/git/week1/session-playground/oranges-file.txt From e35bcac553d4a6873a24d4f2ac7fbe06ec2392c6 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Tue, 21 Oct 2025 16:27:58 +0200 Subject: [PATCH 008/113] and colors.txt --- courses/foundation/git/week1/session-playground/colors.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 courses/foundation/git/week1/session-playground/colors.txt diff --git a/courses/foundation/git/week1/session-playground/colors.txt b/courses/foundation/git/week1/session-playground/colors.txt new file mode 100644 index 000000000..e391456a3 --- /dev/null +++ b/courses/foundation/git/week1/session-playground/colors.txt @@ -0,0 +1,2 @@ +Red +Yellow \ No newline at end of file From 628546d16c14e603d29c247fe8483fc7453bf9de Mon Sep 17 00:00:00 2001 From: Jessica Brennan-Kavanagh Date: Tue, 21 Oct 2025 16:31:42 +0200 Subject: [PATCH 009/113] Add Blue color to colors.txt --- courses/foundation/git/week1/session-playground/colors.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/courses/foundation/git/week1/session-playground/colors.txt b/courses/foundation/git/week1/session-playground/colors.txt index e391456a3..729594a0a 100644 --- a/courses/foundation/git/week1/session-playground/colors.txt +++ b/courses/foundation/git/week1/session-playground/colors.txt @@ -1,2 +1,3 @@ +Blue Red -Yellow \ No newline at end of file +Yellow From 3a67d1d2bfa4a9297223b52b4e4e95689735ef3a Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Tue, 21 Oct 2025 16:32:35 +0200 Subject: [PATCH 010/113] added orange to colors.txt --- courses/foundation/git/week1/session-playground/colors.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/courses/foundation/git/week1/session-playground/colors.txt b/courses/foundation/git/week1/session-playground/colors.txt index e391456a3..aedfe69df 100644 --- a/courses/foundation/git/week1/session-playground/colors.txt +++ b/courses/foundation/git/week1/session-playground/colors.txt @@ -1,2 +1,3 @@ Red -Yellow \ No newline at end of file +Yellow +Orange \ No newline at end of file From 40f966310f5e95751fbec3a7b766fe90e8b0b033 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Tue, 21 Oct 2025 16:38:01 +0200 Subject: [PATCH 011/113] added movies.txt --- courses/foundation/git/week1/session-playground/movies.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 courses/foundation/git/week1/session-playground/movies.txt diff --git a/courses/foundation/git/week1/session-playground/movies.txt b/courses/foundation/git/week1/session-playground/movies.txt new file mode 100644 index 000000000..907361979 --- /dev/null +++ b/courses/foundation/git/week1/session-playground/movies.txt @@ -0,0 +1,2 @@ +Cinderella +The Little Mermaid \ No newline at end of file From c280cbee5dadac73ff24b7be69f1fe5ad6bbb405 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Tue, 21 Oct 2025 18:38:04 +0200 Subject: [PATCH 012/113] merging exercise-3 --- .../foundation/git/week1/session-playground/my-assignment.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 courses/foundation/git/week1/session-playground/my-assignment.txt diff --git a/courses/foundation/git/week1/session-playground/my-assignment.txt b/courses/foundation/git/week1/session-playground/my-assignment.txt new file mode 100644 index 000000000..94984a082 --- /dev/null +++ b/courses/foundation/git/week1/session-playground/my-assignment.txt @@ -0,0 +1,2 @@ +git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, +git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git,git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, git, \ No newline at end of file From 64d7e99a733a5d346c769407103275e812a0c6a3 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 29 Oct 2025 09:27:53 +0100 Subject: [PATCH 013/113] added list of the prompts I will use to create the pages --- .../week-1/assignment/prompts.txt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 courses/foundation/intro-to-using-ai/week-1/assignment/prompts.txt diff --git a/courses/foundation/intro-to-using-ai/week-1/assignment/prompts.txt b/courses/foundation/intro-to-using-ai/week-1/assignment/prompts.txt new file mode 100644 index 000000000..ef0663daf --- /dev/null +++ b/courses/foundation/intro-to-using-ai/week-1/assignment/prompts.txt @@ -0,0 +1,16 @@ +I would like to make a simple HTML page that introduces me and my interests. +Begin by creating an HTML document and adding a heading with the text "About Me" at the top. + +Add a short introduction as a paragraph element below the heading. + +Add an unordered list of my interests (juggling, games, programming). + +Centre the heading. + +Change the font to a custom font. + +Add a background colour. + +Add a "fun" button somewhere on the page which changes the background colour to a random colour when clicked. + +Make this page responsive, using media queries to style the page for mobile and desktop size screens. \ No newline at end of file From 472fbcde8ec5226f6163612139e540dd6009642b Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 29 Oct 2025 09:29:48 +0100 Subject: [PATCH 014/113] implemented prompt 1 --- .../week-1/assignment/ai-index-1.html | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html diff --git a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html new file mode 100644 index 000000000..8b321e748 --- /dev/null +++ b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html @@ -0,0 +1,11 @@ + + + + + + About Me + + +

About Me

+ + \ No newline at end of file From 0194a5b3a0dd91ce7243d01e0349a11faa4b8d13 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 29 Oct 2025 09:30:21 +0100 Subject: [PATCH 015/113] implemented prompt 2 --- .../intro-to-using-ai/week-1/assignment/ai-index-1.html | 1 + 1 file changed, 1 insertion(+) diff --git a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html index 8b321e748..f0e19e9ca 100644 --- a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html +++ b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html @@ -7,5 +7,6 @@

About Me

+

Hello! I'm a passionate learner currently studying web development through the Hack Your Future program. I'm excited about building my skills in programming and creating meaningful digital experiences.

\ No newline at end of file From 683ac9dc7cf0de1aa254193c81917ed19c234c7d Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 29 Oct 2025 09:31:13 +0100 Subject: [PATCH 016/113] implemented prompt 3 --- .../intro-to-using-ai/week-1/assignment/ai-index-1.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html index f0e19e9ca..5762745aa 100644 --- a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html +++ b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html @@ -8,5 +8,11 @@

About Me

Hello! I'm a passionate learner currently studying web development through the Hack Your Future program. I'm excited about building my skills in programming and creating meaningful digital experiences.

+

My Interests

+
    +
  • Juggling
  • +
  • Games
  • +
  • Programming
  • +
\ No newline at end of file From 9569cc6e15a33995ced9da4a5b03033141eb4e41 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 29 Oct 2025 09:32:02 +0100 Subject: [PATCH 017/113] implemented prompt 4 --- .../intro-to-using-ai/week-1/assignment/ai-index-1.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html index 5762745aa..327bde4f2 100644 --- a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html +++ b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html @@ -4,6 +4,11 @@ About Me +

About Me

From 60215be7c037bf6b092e4803bbb10695353c7c4f Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 29 Oct 2025 09:33:29 +0100 Subject: [PATCH 018/113] implemented prompt 5 --- .../intro-to-using-ai/week-1/assignment/ai-index-1.html | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html index 327bde4f2..87a62a54a 100644 --- a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html +++ b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html @@ -4,7 +4,13 @@ About Me + + + @@ -26,5 +40,14 @@

My Interests

  • Games
  • Programming
  • + + + \ No newline at end of file From 898c03e8beb56764203de9855d2902f2cf774481 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 29 Oct 2025 09:35:27 +0100 Subject: [PATCH 021/113] implemented prompt 8 --- .../week-1/assignment/ai-index-1.html | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html index 7796162a8..3b2b735a5 100644 --- a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html +++ b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-1.html @@ -11,9 +11,24 @@ body { font-family: 'Poppins', sans-serif; background-color: #f0f8ff; + margin: 0; + padding: 20px; + max-width: 800px; + margin: 0 auto; + line-height: 1.6; } h1 { text-align: center; + font-size: 2.5rem; + } + h2 { + font-size: 1.5rem; + } + p { + font-size: 1.1rem; + } + ul { + font-size: 1.1rem; } #funButton { display: block; @@ -29,6 +44,60 @@ #funButton:hover { background-color: #45a049; } + + /* Mobile styles (768px and below) */ + @media screen and (max-width: 768px) { + body { + padding: 15px; + } + h1 { + font-size: 2rem; + } + h2 { + font-size: 1.3rem; + } + p, ul { + font-size: 1rem; + } + #funButton { + width: 100%; + max-width: 300px; + padding: 15px; + font-size: 18px; + } + } + + /* Extra small mobile styles (480px and below) */ + @media screen and (max-width: 480px) { + body { + padding: 10px; + } + h1 { + font-size: 1.8rem; + } + h2 { + font-size: 1.2rem; + } + p, ul { + font-size: 0.9rem; + } + } + + /* Desktop styles (1024px and above) */ + @media screen and (min-width: 1024px) { + body { + padding: 40px; + } + h1 { + font-size: 3rem; + } + h2 { + font-size: 1.8rem; + } + p, ul { + font-size: 1.2rem; + } + } From a75e3a4dcb3253f16f937fc4b749198acfd01574 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 29 Oct 2025 09:37:06 +0100 Subject: [PATCH 022/113] implemented prompt 1a --- .../week-1/assignment/ai-index-2.html | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html diff --git a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html new file mode 100644 index 000000000..8b321e748 --- /dev/null +++ b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html @@ -0,0 +1,11 @@ + + + + + + About Me + + +

    About Me

    + + \ No newline at end of file From b670e7daa7439841aceabe2c1600e7984269f853 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 29 Oct 2025 09:37:47 +0100 Subject: [PATCH 023/113] implemented prompt 2a --- .../intro-to-using-ai/week-1/assignment/ai-index-2.html | 1 + 1 file changed, 1 insertion(+) diff --git a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html index 8b321e748..9b5ea9951 100644 --- a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html +++ b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html @@ -7,5 +7,6 @@

    About Me

    +

    Hello! My name is [Your Name] and I'm excited to share a bit about myself. I'm currently learning web development and exploring the world of programming. This page is a simple introduction to who I am and what interests me.

    \ No newline at end of file From 4bb7a775aca193ed2c066f42f27e63f100683c63 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 29 Oct 2025 09:38:20 +0100 Subject: [PATCH 024/113] implemented prompt 3a --- .../intro-to-using-ai/week-1/assignment/ai-index-2.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html index 9b5ea9951..3d8834950 100644 --- a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html +++ b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html @@ -8,5 +8,12 @@

    About Me

    Hello! My name is [Your Name] and I'm excited to share a bit about myself. I'm currently learning web development and exploring the world of programming. This page is a simple introduction to who I am and what interests me.

    + +

    My Interests

    +
      +
    • Juggling
    • +
    • Games
    • +
    • Programming
    • +
    \ No newline at end of file From 3684bc1eb9278ae6ec9f483d59787dfdd533ec32 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 29 Oct 2025 09:38:49 +0100 Subject: [PATCH 025/113] implemented prompt 4a --- .../intro-to-using-ai/week-1/assignment/ai-index-2.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html index 3d8834950..69f253240 100644 --- a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html +++ b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html @@ -4,6 +4,11 @@ About Me +

    About Me

    From c8d835a9315fa42bd5ed25a6c227a4b9bd0f446a Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 29 Oct 2025 09:39:28 +0100 Subject: [PATCH 026/113] implemented prompt 5a --- .../intro-to-using-ai/week-1/assignment/ai-index-2.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html index 69f253240..c96524907 100644 --- a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html +++ b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html @@ -4,7 +4,12 @@ About Me + @@ -26,5 +44,15 @@

    My Interests

  • Games
  • Programming
  • + + + + \ No newline at end of file From 98badbe4e95e3cceae0b72f26d9df75138530fe1 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 29 Oct 2025 09:42:02 +0100 Subject: [PATCH 029/113] implemented prompt 8a --- .../week-1/assignment/ai-index-2.html | 113 ++++++++++++++++-- 1 file changed, 100 insertions(+), 13 deletions(-) diff --git a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html index 393175a08..692f9cb55 100644 --- a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html +++ b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-2.html @@ -9,16 +9,44 @@ body { font-family: 'Poppins', sans-serif; background-color: #f0f8ff; + margin: 0; + padding: 20px; + line-height: 1.6; + } + + .container { + max-width: 800px; + margin: 0 auto; } h1 { text-align: center; + font-size: 2.5rem; + margin-bottom: 1rem; + } + + h2 { + font-size: 1.5rem; + margin-top: 2rem; + } + + p { + font-size: 1.1rem; + margin-bottom: 1.5rem; + } + + ul { + font-size: 1.1rem; + } + + li { + margin-bottom: 0.5rem; } .fun-button { display: block; - margin: 20px auto; - padding: 10px 20px; + margin: 30px auto; + padding: 12px 24px; background-color: #ff6b6b; color: white; border: none; @@ -32,20 +60,79 @@ .fun-button:hover { background-color: #ff5252; } + + /* Mobile styles (up to 768px) */ + @media screen and (max-width: 768px) { + body { + padding: 15px; + } + + h1 { + font-size: 2rem; + } + + h2 { + font-size: 1.3rem; + } + + p, ul { + font-size: 1rem; + } + + .fun-button { + width: 90%; + max-width: 300px; + padding: 15px; + font-size: 18px; + } + } + + /* Tablet styles (769px to 1024px) */ + @media screen and (min-width: 769px) and (max-width: 1024px) { + body { + padding: 25px; + } + + h1 { + font-size: 2.3rem; + } + } + + /* Desktop styles (1025px and up) */ + @media screen and (min-width: 1025px) { + body { + padding: 40px; + } + + h1 { + font-size: 3rem; + } + + p, ul { + font-size: 1.2rem; + } + + .fun-button { + padding: 15px 30px; + font-size: 18px; + } + } -

    About Me

    -

    Hello! My name is [Your Name] and I'm excited to share a bit about myself. I'm currently learning web development and exploring the world of programming. This page is a simple introduction to who I am and what interests me.

    - -

    My Interests

    -
      -
    • Juggling
    • -
    • Games
    • -
    • Programming
    • -
    - - +
    +

    About Me

    +

    Hello! My name is [Your Name] and I'm excited to share a bit about myself. I'm currently learning web development and exploring the world of programming. This page is a simple introduction to who I am and what interests me.

    + +

    My Interests

    +
      +
    • Juggling
    • +
    • Games
    • +
    • Programming
    • +
    + + +
    + \ No newline at end of file From 9c27e9ae2047661686ab1d46add33ce58141482d Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 29 Oct 2025 09:47:50 +0100 Subject: [PATCH 038/113] implemented prompt 8b --- .../week-1/assignment/ai-index-b.html | 65 ++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-b.html b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-b.html index 4d7920fdf..4faa61c9a 100644 --- a/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-b.html +++ b/courses/foundation/intro-to-using-ai/week-1/assignment/ai-index-b.html @@ -9,14 +9,35 @@ body { font-family: 'Poppins', sans-serif; background-color: #f5f5f5; + margin: 0; + padding: 20px; + max-width: 800px; + margin: 0 auto; + line-height: 1.6; } h1 { text-align: center; + font-size: 2.5rem; + margin-bottom: 1rem; + } + h2 { + font-size: 1.8rem; + margin-top: 2rem; + } + p { + font-size: 1.1rem; + margin-bottom: 1.5rem; + } + ul { + font-size: 1.1rem; + } + li { + margin-bottom: 0.5rem; } .fun-button { display: block; margin: 20px auto; - padding: 10px 20px; + padding: 12px 24px; background-color: #4CAF50; color: white; border: none; @@ -24,10 +45,52 @@ cursor: pointer; font-family: 'Poppins', sans-serif; font-size: 16px; + transition: background-color 0.3s ease; } .fun-button:hover { background-color: #45a049; } + + /* Mobile styles */ + @media (max-width: 768px) { + body { + padding: 15px; + } + h1 { + font-size: 2rem; + } + h2 { + font-size: 1.5rem; + } + p, ul { + font-size: 1rem; + } + .fun-button { + padding: 10px 20px; + font-size: 14px; + margin: 15px auto; + } + } + + /* Desktop styles */ + @media (min-width: 1024px) { + body { + padding: 40px; + } + h1 { + font-size: 3rem; + } + h2 { + font-size: 2rem; + } + p, ul { + font-size: 1.2rem; + } + .fun-button { + padding: 15px 30px; + font-size: 18px; + } + } From c71e336df12b0078b07c80ef93214081841ecf1e Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 29 Oct 2025 10:02:02 +0100 Subject: [PATCH 039/113] added final reflections on exercise --- .../intro-to-using-ai/week-1/assignment/reflections.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 courses/foundation/intro-to-using-ai/week-1/assignment/reflections.txt diff --git a/courses/foundation/intro-to-using-ai/week-1/assignment/reflections.txt b/courses/foundation/intro-to-using-ai/week-1/assignment/reflections.txt new file mode 100644 index 000000000..3ad380828 --- /dev/null +++ b/courses/foundation/intro-to-using-ai/week-1/assignment/reflections.txt @@ -0,0 +1,3 @@ +I decided to approach this exercise by writing a set of 8 prompts of varying specificity and then tasking the LLM with building the same page three times to compare the different outputs. +As expected, the basic HTML structure is consistent accross the three documents. Once more complex elements with less specificity (such as the button and the responsiveness) were included, consistency begins to drop. Buttons are labeled differently and are different sizes and colours. Responsiveness, though apparently functioning correctly in all three instances, is structured very differently. +My main takeaway from this exercise is a nagging feeling that it sucked the joy out of the experience of creating this simple page. \ No newline at end of file From 636a7c7cae4baea448668375fe90960e2375c86c Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 3 Nov 2025 09:23:57 +0100 Subject: [PATCH 040/113] added week 1 assignments --- .../foundation/intro-to-javascript/week-1/ageify.js | 3 +++ .../foundation/intro-to-javascript/week-1/ezNamey.js | 6 ++++++ .../intro-to-javascript/week-1/goodBoyOldBoy.js | 10 ++++++++++ .../intro-to-javascript/week-1/houseyPricey.js | 10 ++++++++++ 4 files changed, 29 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-1/ageify.js create mode 100644 courses/foundation/intro-to-javascript/week-1/ezNamey.js create mode 100644 courses/foundation/intro-to-javascript/week-1/goodBoyOldBoy.js create mode 100644 courses/foundation/intro-to-javascript/week-1/houseyPricey.js diff --git a/courses/foundation/intro-to-javascript/week-1/ageify.js b/courses/foundation/intro-to-javascript/week-1/ageify.js new file mode 100644 index 000000000..588e50a63 --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-1/ageify.js @@ -0,0 +1,3 @@ +const ageify = (birthYear, futureYear) => `You will be ${futureYear - birthYear} years old in ${futureYear}`; + +console.log(ageify(1989, 2050)); \ No newline at end of file diff --git a/courses/foundation/intro-to-javascript/week-1/ezNamey.js b/courses/foundation/intro-to-javascript/week-1/ezNamey.js new file mode 100644 index 000000000..3ef1bcded --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-1/ezNamey.js @@ -0,0 +1,6 @@ +firstParticles = ['Shop', 'Drink', 'Eat', 'Buy', 'Spend', 'Get', 'Bet', 'Swipe', 'Game', 'Pic', 'View'] +secondParticles = ['r' ,'s\'r\'Us', 'ify', 'ly', 'hub', 'ful', 'book', 'Saver', 'Finder', 'tube'] + +getRandom = (arr) => arr[Math.floor(Math.random() * arr.length)]; + +ezNamey = () => `Your new app name is ${getRandom(firstParticles)}${getRandom(secondParticles)}!`; \ No newline at end of file diff --git a/courses/foundation/intro-to-javascript/week-1/goodBoyOldBoy.js b/courses/foundation/intro-to-javascript/week-1/goodBoyOldBoy.js new file mode 100644 index 000000000..77a0ad730 --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-1/goodBoyOldBoy.js @@ -0,0 +1,10 @@ +function dogify(dogYearOfBirth, dogYearFuture, shouldShowResultInDogYears) { + const humanYears = dogYearFuture - dogYearOfBirth + const dogYears = humanYears * 7; + return shouldShowResultInDogYears === false ? + `Your dog will be ${humanYears} human years old in ${dogYearFuture}` : + `Your dog will be ${dogYears} dog years old in ${dogYearFuture}`; +} + +console.log(dogify(2022, 2031, true)); +console.log(dogify(2022, 2031, false)); \ No newline at end of file diff --git a/courses/foundation/intro-to-javascript/week-1/houseyPricey.js b/courses/foundation/intro-to-javascript/week-1/houseyPricey.js new file mode 100644 index 000000000..4248a3f13 --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-1/houseyPricey.js @@ -0,0 +1,10 @@ +function ripOffDetector(width, depth, height, gardenSizeInM2, clientName, quotedPrice) { + const volumeInMeters = width * depth * height; + const housePrice = (volumeInMeters * 2.5 * 1000) + (gardenSizeInM2 * 300); + return quotedPrice <= housePrice ? + `Looking good, ${clientName}, you should buy!` : + `What a rip off! Get out of there ${clientName}!`; +} + +console.log(ripOffDetector(8, 10, 10, 100, 'Peter', 2500000)); +console.log(ripOffDetector(5, 11, 8, 70, 'Julia', 1000000)); \ No newline at end of file From 99f4eb0dd375b74705ba6b4e100f307a67cf54fe Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Tue, 4 Nov 2025 17:22:17 +0100 Subject: [PATCH 041/113] updated after feedback --- .../intro-to-javascript/week-1/ageify.js | 6 ++-- .../intro-to-javascript/week-1/ezNamey.js | 9 +++--- .../week-1/goodBoyOldBoy.js | 22 ++++++++------ .../week-1/houseyPricey.js | 29 +++++++++++++++---- 4 files changed, 45 insertions(+), 21 deletions(-) diff --git a/courses/foundation/intro-to-javascript/week-1/ageify.js b/courses/foundation/intro-to-javascript/week-1/ageify.js index 588e50a63..f455ad006 100644 --- a/courses/foundation/intro-to-javascript/week-1/ageify.js +++ b/courses/foundation/intro-to-javascript/week-1/ageify.js @@ -1,3 +1,5 @@ -const ageify = (birthYear, futureYear) => `You will be ${futureYear - birthYear} years old in ${futureYear}`; +const yearOfBirth = 1989; +const yearFuture = 2030; +const age = yearFuture - yearOfBirth; -console.log(ageify(1989, 2050)); \ No newline at end of file +console.log("You will be " + age + " years old in " + yearFuture); \ No newline at end of file diff --git a/courses/foundation/intro-to-javascript/week-1/ezNamey.js b/courses/foundation/intro-to-javascript/week-1/ezNamey.js index 3ef1bcded..2339926e2 100644 --- a/courses/foundation/intro-to-javascript/week-1/ezNamey.js +++ b/courses/foundation/intro-to-javascript/week-1/ezNamey.js @@ -1,6 +1,7 @@ -firstParticles = ['Shop', 'Drink', 'Eat', 'Buy', 'Spend', 'Get', 'Bet', 'Swipe', 'Game', 'Pic', 'View'] -secondParticles = ['r' ,'s\'r\'Us', 'ify', 'ly', 'hub', 'ful', 'book', 'Saver', 'Finder', 'tube'] +const firstWords = ["Easy", "Awesome", "Corporate", "Cool", "Fun", "Good", "Great", "Better", "Superb", "Yes"]; +const secondWords = ["Corporation", "Company", "Firm", "Business", "Fund", "Alliance", "Equity", "Capital", "Finance", "Holdings"]; -getRandom = (arr) => arr[Math.floor(Math.random() * arr.length)]; +const getRandom = (arr) => arr[Math.floor(Math.random() * arr.length)]; +const startupName = getRandom(firstWords) + " " + getRandom(secondWords); -ezNamey = () => `Your new app name is ${getRandom(firstParticles)}${getRandom(secondParticles)}!`; \ No newline at end of file +console.log("Your new app name is " + startupName + "!"); \ No newline at end of file diff --git a/courses/foundation/intro-to-javascript/week-1/goodBoyOldBoy.js b/courses/foundation/intro-to-javascript/week-1/goodBoyOldBoy.js index 77a0ad730..481f6f917 100644 --- a/courses/foundation/intro-to-javascript/week-1/goodBoyOldBoy.js +++ b/courses/foundation/intro-to-javascript/week-1/goodBoyOldBoy.js @@ -1,10 +1,14 @@ -function dogify(dogYearOfBirth, dogYearFuture, shouldShowResultInDogYears) { - const humanYears = dogYearFuture - dogYearOfBirth - const dogYears = humanYears * 7; - return shouldShowResultInDogYears === false ? - `Your dog will be ${humanYears} human years old in ${dogYearFuture}` : - `Your dog will be ${dogYears} dog years old in ${dogYearFuture}`; -} -console.log(dogify(2022, 2031, true)); -console.log(dogify(2022, 2031, false)); \ No newline at end of file +const dogYearOfBirth = 2023; +const dogYearFuture = 2033; +const dogYear = (dogYearFuture - dogYearOfBirth)*7; + +let shouldShowResultInDogYears = true; +shouldShowResultInDogYears ? + console.log(`Your dog will be ${dogYear} dog years old in ${dogYearFuture}`) : + console.log(`Your dog will be ${dogYearFuture - dogYearOfBirth} human years old in ${dogYearFuture}`); + +shouldShowResultInDogYears = false; +shouldShowResultInDogYears ? + console.log(`Your dog will be ${dogYear} dog years old in ${dogYearFuture}`) : + console.log(`Your dog will be ${dogYearFuture - dogYearOfBirth} human years old in ${dogYearFuture}`); \ No newline at end of file diff --git a/courses/foundation/intro-to-javascript/week-1/houseyPricey.js b/courses/foundation/intro-to-javascript/week-1/houseyPricey.js index 4248a3f13..3c8a68029 100644 --- a/courses/foundation/intro-to-javascript/week-1/houseyPricey.js +++ b/courses/foundation/intro-to-javascript/week-1/houseyPricey.js @@ -1,10 +1,27 @@ -function ripOffDetector(width, depth, height, gardenSizeInM2, clientName, quotedPrice) { - const volumeInMeters = width * depth * height; - const housePrice = (volumeInMeters * 2.5 * 1000) + (gardenSizeInM2 * 300); - return quotedPrice <= housePrice ? +function ripOffDetector(clientName) { + const volumeInMeters = customerData[clientName].width * customerData[clientName].depth * customerData[clientName].height; + const housePrice = (volumeInMeters * 2.5 * 1000) + (customerData[clientName].gardenSizeInM2 * 300); + return customerData[clientName].quotedPrice <= housePrice ? `Looking good, ${clientName}, you should buy!` : `What a rip off! Get out of there ${clientName}!`; } -console.log(ripOffDetector(8, 10, 10, 100, 'Peter', 2500000)); -console.log(ripOffDetector(5, 11, 8, 70, 'Julia', 1000000)); \ No newline at end of file +const customerData = { + Peter: { + quotedPrice: 2500000, + gardenSizeInM2: 100, + width: 8, + depth: 10, + height: 10 + }, + Julia: { + quotedPrice: 1000000, + gardenSizeInM2: 70, + width: 5, + depth: 11, + height: 8 + } +} + +console.log(ripOffDetector('Peter')); +console.log(ripOffDetector('Julia')); \ No newline at end of file From cb72a12cfac5adc183715cc65b1589eb31d8af32 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 5 Nov 2025 14:15:00 +0100 Subject: [PATCH 042/113] updated after second round of feedback --- .../intro-to-javascript/week-1/goodBoyOldBoy.js | 11 ++++++----- .../intro-to-javascript/week-1/houseyPricey.js | 8 ++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/courses/foundation/intro-to-javascript/week-1/goodBoyOldBoy.js b/courses/foundation/intro-to-javascript/week-1/goodBoyOldBoy.js index 481f6f917..db752f52c 100644 --- a/courses/foundation/intro-to-javascript/week-1/goodBoyOldBoy.js +++ b/courses/foundation/intro-to-javascript/week-1/goodBoyOldBoy.js @@ -1,14 +1,15 @@ const dogYearOfBirth = 2023; const dogYearFuture = 2033; -const dogYear = (dogYearFuture - dogYearOfBirth)*7; +const humanYears = dogYearFuture - dogYearOfBirth +const dogYears = humanYears*7; let shouldShowResultInDogYears = true; shouldShowResultInDogYears ? - console.log(`Your dog will be ${dogYear} dog years old in ${dogYearFuture}`) : - console.log(`Your dog will be ${dogYearFuture - dogYearOfBirth} human years old in ${dogYearFuture}`); + console.log(`Your dog will be ${dogYears} dog years old in ${dogYearFuture}`) : + console.log(`Your dog will be ${humanYears} human years old in ${dogYearFuture}`); shouldShowResultInDogYears = false; shouldShowResultInDogYears ? - console.log(`Your dog will be ${dogYear} dog years old in ${dogYearFuture}`) : - console.log(`Your dog will be ${dogYearFuture - dogYearOfBirth} human years old in ${dogYearFuture}`); \ No newline at end of file + console.log(`Your dog will be ${dogYears} dog years old in ${dogYearFuture}`) : + console.log(`Your dog will be ${humanYears} human years old in ${dogYearFuture}`); \ No newline at end of file diff --git a/courses/foundation/intro-to-javascript/week-1/houseyPricey.js b/courses/foundation/intro-to-javascript/week-1/houseyPricey.js index 3c8a68029..89734c35f 100644 --- a/courses/foundation/intro-to-javascript/week-1/houseyPricey.js +++ b/courses/foundation/intro-to-javascript/week-1/houseyPricey.js @@ -2,8 +2,8 @@ function ripOffDetector(clientName) { const volumeInMeters = customerData[clientName].width * customerData[clientName].depth * customerData[clientName].height; const housePrice = (volumeInMeters * 2.5 * 1000) + (customerData[clientName].gardenSizeInM2 * 300); return customerData[clientName].quotedPrice <= housePrice ? - `Looking good, ${clientName}, you should buy!` : - `What a rip off! Get out of there ${clientName}!`; + console.log(`Looking good, ${clientName}, you should buy!`) : + console.log(`What a rip off! Get out of there ${clientName}!`); } const customerData = { @@ -23,5 +23,5 @@ const customerData = { } } -console.log(ripOffDetector('Peter')); -console.log(ripOffDetector('Julia')); \ No newline at end of file +ripOffDetector("Peter"); +ripOffDetector("Julia"); \ No newline at end of file From e6209777f24ca644894ce25a7376ff667b73b160 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 5 Nov 2025 14:16:47 +0100 Subject: [PATCH 043/113] removed return statement from ripOffDetector --- courses/foundation/intro-to-javascript/week-1/houseyPricey.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/courses/foundation/intro-to-javascript/week-1/houseyPricey.js b/courses/foundation/intro-to-javascript/week-1/houseyPricey.js index 89734c35f..cbc98b061 100644 --- a/courses/foundation/intro-to-javascript/week-1/houseyPricey.js +++ b/courses/foundation/intro-to-javascript/week-1/houseyPricey.js @@ -1,7 +1,7 @@ function ripOffDetector(clientName) { const volumeInMeters = customerData[clientName].width * customerData[clientName].depth * customerData[clientName].height; const housePrice = (volumeInMeters * 2.5 * 1000) + (customerData[clientName].gardenSizeInM2 * 300); - return customerData[clientName].quotedPrice <= housePrice ? + customerData[clientName].quotedPrice <= housePrice ? console.log(`Looking good, ${clientName}, you should buy!`) : console.log(`What a rip off! Get out of there ${clientName}!`); } From cdff2820a0bc5ba15980f42b0fa9df57b28de693 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Tue, 11 Nov 2025 19:12:41 +0100 Subject: [PATCH 044/113] added getFullName.js --- .../intro-to-javascript/week-2/getFullName.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-2/getFullName.js diff --git a/courses/foundation/intro-to-javascript/week-2/getFullName.js b/courses/foundation/intro-to-javascript/week-2/getFullName.js new file mode 100644 index 000000000..655a94105 --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-2/getFullName.js @@ -0,0 +1,43 @@ +const honorifics = { + man: "Mr.", + woman: "Ms.", + "non-binary": "Mx." +} + +const passengers = [ + { + firstName: "John", + secondName: "Smith", + gender: "man", + formal: false + }, + { + firstName: "Jane", + secondName: "Smythe", + gender: "woman", + formal: true + }, + { + firstName: "Jayden", + secondName: "Smith", + gender: "non-binary", + formal: true + } +] + +let formal = false; +let gender = "man"; + +function getFullName(firstName, secondName) { + var passenger = passengers.find(obj => { + return obj.firstName === firstName && obj.secondName === secondName; + }); + + if (!passenger) {return "No passenger found"} + return passenger.formal ? `${honorifics[passenger.gender]} ${passenger.firstName} ${passenger.secondName}` : `${passenger.firstName} ${passenger.secondName}` +} + +console.log(getFullName("John", "Smith")); +console.log(getFullName("Jane", "Smythe")); +console.log(getFullName("Jayden", "Smith")); +console.log(getFullName("Jane", "Smith")); \ No newline at end of file From 35978c91331a7cc7740af7846243928039063913 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Tue, 11 Nov 2025 19:15:24 +0100 Subject: [PATCH 045/113] improved readability of getFullName.js --- .../intro-to-javascript/week-2/getFullName.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/courses/foundation/intro-to-javascript/week-2/getFullName.js b/courses/foundation/intro-to-javascript/week-2/getFullName.js index 655a94105..355e9ccf8 100644 --- a/courses/foundation/intro-to-javascript/week-2/getFullName.js +++ b/courses/foundation/intro-to-javascript/week-2/getFullName.js @@ -33,9 +33,13 @@ function getFullName(firstName, secondName) { return obj.firstName === firstName && obj.secondName === secondName; }); - if (!passenger) {return "No passenger found"} - return passenger.formal ? `${honorifics[passenger.gender]} ${passenger.firstName} ${passenger.secondName}` : `${passenger.firstName} ${passenger.secondName}` -} + if (!passenger) { + return "No passenger found" + } else { + return passenger.formal ? + `${honorifics[passenger.gender]} ${passenger.firstName} ${passenger.secondName}` : + `${passenger.firstName} ${passenger.secondName}`}; +}; console.log(getFullName("John", "Smith")); console.log(getFullName("Jane", "Smythe")); From b7d4afd9432d8c5eb4692102f03c950403028bff Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Tue, 11 Nov 2025 19:27:52 +0100 Subject: [PATCH 046/113] added getWeekday.js --- .../intro-to-javascript/week-2/getWeekday.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-2/getWeekday.js diff --git a/courses/foundation/intro-to-javascript/week-2/getWeekday.js b/courses/foundation/intro-to-javascript/week-2/getWeekday.js new file mode 100644 index 000000000..4adcbccd5 --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-2/getWeekday.js @@ -0,0 +1,20 @@ +const weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday"] +const currentDate = new Date(); +const currentDay = currentDate.getDay(); + +function getWeekday(num) { + const difference = num % 7; + const currentWeekday = currentDay + difference; + if (num === 0) { + return "Today" + } else { + return currentWeekday > 6 ? + weekdays[currentWeekday - 7] : + weekdays[currentWeekday]; + }; +} + +console.log(getWeekday(0)); +console.log(getWeekday(1)); +console.log(getWeekday(9)); +console.log(getWeekday(17)); \ No newline at end of file From fe5f0c0b6f36c65a8d8a745b288c4d0b397f652d Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Tue, 11 Nov 2025 21:02:37 +0100 Subject: [PATCH 047/113] added clothingPicker.js --- .../intro-to-javascript/week-2/clothingPicker.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-2/clothingPicker.js diff --git a/courses/foundation/intro-to-javascript/week-2/clothingPicker.js b/courses/foundation/intro-to-javascript/week-2/clothingPicker.js new file mode 100644 index 000000000..9b10a8cab --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-2/clothingPicker.js @@ -0,0 +1,12 @@ +function clothingPicker(temp) { + return temp >= 20 ? "T-Shirt" : + temp >= 15 ? "Sweater" : + temp >= 10 ? "Coat" : + temp >= 0 ? "Puffer jacket" : + temp < 0 ? "Slippers and pajamas" : + "Invalid temperature entered" ; +} + +console.log(clothingPicker(18)); +console.log(clothingPicker(-3)); +console.log(clothingPicker("very cold")); \ No newline at end of file From 95fb94e08e035fb4c14b5238859585ebe5f8618a Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Tue, 11 Nov 2025 21:08:01 +0100 Subject: [PATCH 048/113] added studentManager.js --- .../intro-to-javascript/week-2/studentManager.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-2/studentManager.js diff --git a/courses/foundation/intro-to-javascript/week-2/studentManager.js b/courses/foundation/intro-to-javascript/week-2/studentManager.js new file mode 100644 index 000000000..c724a8bcd --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-2/studentManager.js @@ -0,0 +1,11 @@ +const class07Students = []; + +const addStudentToClass = studentName => class07Students.push(studentName); + +const getNumberOfStudents = () => class07Students.length; + +console.log(getNumberOfStudents()); +addStudentToClass("Jenny"); +console.log(getNumberOfStudents()); +addStudentToClass("Jerry"); +console.log(getNumberOfStudents()); \ No newline at end of file From c638fa616993982bbf5f9dae0cb08323f48c4127 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Tue, 11 Nov 2025 21:17:25 +0100 Subject: [PATCH 049/113] refactored studentManager.js to meet all requirements --- .../week-2/studentManager.js | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/courses/foundation/intro-to-javascript/week-2/studentManager.js b/courses/foundation/intro-to-javascript/week-2/studentManager.js index c724a8bcd..57da3890a 100644 --- a/courses/foundation/intro-to-javascript/week-2/studentManager.js +++ b/courses/foundation/intro-to-javascript/week-2/studentManager.js @@ -1,11 +1,22 @@ const class07Students = []; -const addStudentToClass = studentName => class07Students.push(studentName); +function addStudentToClass (studentName) { + return studentName.length < 1 ? + "Invalid name entered" : -const getNumberOfStudents = () => class07Students.length; + studentName === "The Queen" ? + class07Students.push(studentName) : -console.log(getNumberOfStudents()); -addStudentToClass("Jenny"); -console.log(getNumberOfStudents()); -addStudentToClass("Jerry"); -console.log(getNumberOfStudents()); \ No newline at end of file + getNumberOfStudents() < 7 && !class07Students.includes(studentName) ? + class07Students.push(studentName) : + + getNumberOfStudents() > 6 ? + "Cannot add more students to class 07" : + + class07Students.includes(studentName) ? + `Student ${studentName} is already in the class` : + + "Invalid name entered"; +}; + +const getNumberOfStudents = () => class07Students.length; \ No newline at end of file From 5e52652b81c3a61ba259fe33d21084dd9c34e8a7 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Tue, 11 Nov 2025 21:32:49 +0100 Subject: [PATCH 050/113] added candyHelper.js --- .../intro-to-javascript/week-2/candyHelper.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-2/candyHelper.js diff --git a/courses/foundation/intro-to-javascript/week-2/candyHelper.js b/courses/foundation/intro-to-javascript/week-2/candyHelper.js new file mode 100644 index 000000000..1342e35e1 --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-2/candyHelper.js @@ -0,0 +1,15 @@ +const pricePerGram = { + sweet: 0.5, + chocolate: 0.7, + toffee: 1.1, + "chewing-gum": 0.03 +}; + +const addCandy = (type, weight) => canBuyMoreCandy() ? boughtCandyPrices.push(pricePerGram[type] * weight) : console.log("Enough candy for you!"); + +const boughtCandyPrices = []; +const calculateTotalSpent = () => boughtCandyPrices.length > 0 ? boughtCandyPrices.reduce((x, y) => x + y) : 0 ; + +const canBuyMoreCandy = () => amountToSpend > calculateTotalSpent(); + +const amountToSpend = Math.random() * 100; \ No newline at end of file From 29f6dd877c75276df7d2dd18216433f244055a39 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Tue, 11 Nov 2025 21:34:11 +0100 Subject: [PATCH 051/113] removed console log tests from files --- .../intro-to-javascript/week-2/clothingPicker.js | 6 +----- .../foundation/intro-to-javascript/week-2/getFullName.js | 7 +------ .../foundation/intro-to-javascript/week-2/getWeekday.js | 7 +------ 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/courses/foundation/intro-to-javascript/week-2/clothingPicker.js b/courses/foundation/intro-to-javascript/week-2/clothingPicker.js index 9b10a8cab..17571254b 100644 --- a/courses/foundation/intro-to-javascript/week-2/clothingPicker.js +++ b/courses/foundation/intro-to-javascript/week-2/clothingPicker.js @@ -5,8 +5,4 @@ function clothingPicker(temp) { temp >= 0 ? "Puffer jacket" : temp < 0 ? "Slippers and pajamas" : "Invalid temperature entered" ; -} - -console.log(clothingPicker(18)); -console.log(clothingPicker(-3)); -console.log(clothingPicker("very cold")); \ No newline at end of file +} \ No newline at end of file diff --git a/courses/foundation/intro-to-javascript/week-2/getFullName.js b/courses/foundation/intro-to-javascript/week-2/getFullName.js index 355e9ccf8..6fce3ba4b 100644 --- a/courses/foundation/intro-to-javascript/week-2/getFullName.js +++ b/courses/foundation/intro-to-javascript/week-2/getFullName.js @@ -39,9 +39,4 @@ function getFullName(firstName, secondName) { return passenger.formal ? `${honorifics[passenger.gender]} ${passenger.firstName} ${passenger.secondName}` : `${passenger.firstName} ${passenger.secondName}`}; -}; - -console.log(getFullName("John", "Smith")); -console.log(getFullName("Jane", "Smythe")); -console.log(getFullName("Jayden", "Smith")); -console.log(getFullName("Jane", "Smith")); \ No newline at end of file +}; \ No newline at end of file diff --git a/courses/foundation/intro-to-javascript/week-2/getWeekday.js b/courses/foundation/intro-to-javascript/week-2/getWeekday.js index 4adcbccd5..f8141a615 100644 --- a/courses/foundation/intro-to-javascript/week-2/getWeekday.js +++ b/courses/foundation/intro-to-javascript/week-2/getWeekday.js @@ -12,9 +12,4 @@ function getWeekday(num) { weekdays[currentWeekday - 7] : weekdays[currentWeekday]; }; -} - -console.log(getWeekday(0)); -console.log(getWeekday(1)); -console.log(getWeekday(9)); -console.log(getWeekday(17)); \ No newline at end of file +}; \ No newline at end of file From a9bcb06a6f90e97c2e25e6fcfc70efc8a8433183 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 12 Nov 2025 14:23:11 +0100 Subject: [PATCH 052/113] refactored getFullName.js to simplify and stay within requirements --- .../intro-to-javascript/week-2/getFullName.js | 46 ++++--------------- 1 file changed, 8 insertions(+), 38 deletions(-) diff --git a/courses/foundation/intro-to-javascript/week-2/getFullName.js b/courses/foundation/intro-to-javascript/week-2/getFullName.js index 6fce3ba4b..d189877af 100644 --- a/courses/foundation/intro-to-javascript/week-2/getFullName.js +++ b/courses/foundation/intro-to-javascript/week-2/getFullName.js @@ -1,42 +1,12 @@ const honorifics = { - man: "Mr.", - woman: "Ms.", - "non-binary": "Mx." -} + man: "Lord", + woman: "Lady", + nonBinary: "Regent" +}; -const passengers = [ - { - firstName: "John", - secondName: "Smith", - gender: "man", - formal: false - }, - { - firstName: "Jane", - secondName: "Smythe", - gender: "woman", - formal: true - }, - { - firstName: "Jayden", - secondName: "Smith", - gender: "non-binary", - formal: true - } -] +const fullName1 = getFullName("John", "Doe"); +const fullName2 = getFullName("Jane", "Doe", true); -let formal = false; -let gender = "man"; - -function getFullName(firstName, secondName) { - var passenger = passengers.find(obj => { - return obj.firstName === firstName && obj.secondName === secondName; - }); - - if (!passenger) { - return "No passenger found" - } else { - return passenger.formal ? - `${honorifics[passenger.gender]} ${passenger.firstName} ${passenger.secondName}` : - `${passenger.firstName} ${passenger.secondName}`}; +function getFullName(firstName, secondName, useFormalName, gender) { + return useFormalName && gender ? `${honorifics[gender]} ${firstName} ${secondName}` : `${firstName} ${secondName}`; }; \ No newline at end of file From 744d6a36b046afbed03c654380681f049b758682 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 12 Nov 2025 14:33:49 +0100 Subject: [PATCH 053/113] refactored studentManager.js to improve if/else logic, remove ternary operators and use consistent function declarations --- .../week-2/studentManager.js | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/courses/foundation/intro-to-javascript/week-2/studentManager.js b/courses/foundation/intro-to-javascript/week-2/studentManager.js index 57da3890a..32476e311 100644 --- a/courses/foundation/intro-to-javascript/week-2/studentManager.js +++ b/courses/foundation/intro-to-javascript/week-2/studentManager.js @@ -1,22 +1,19 @@ const class07Students = []; -function addStudentToClass (studentName) { - return studentName.length < 1 ? - "Invalid name entered" : - - studentName === "The Queen" ? - class07Students.push(studentName) : - - getNumberOfStudents() < 7 && !class07Students.includes(studentName) ? - class07Students.push(studentName) : - - getNumberOfStudents() > 6 ? - "Cannot add more students to class 07" : - - class07Students.includes(studentName) ? - `Student ${studentName} is already in the class` : - - "Invalid name entered"; +function addStudentToClass(studentName) { + if (studentName.length < 1) { + console.log("Invalid name entered"); + } else if (studentName === "The Queen") { + class07Students.push(studentName); + } else if (class07Students.includes(studentName)) { + console.log(`Student ${studentName} is already in the class`); + } else if (getNumberOfStudents() > 6) { + console.log("Cannot add more students to class 07"); + } else { + class07Students.push(studentName); + }; }; -const getNumberOfStudents = () => class07Students.length; \ No newline at end of file +function getNumberOfStudents() { + return class07Students.length; +}; \ No newline at end of file From 78554a455b56592bfe9d78394c9a3ecfb041fe73 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 12 Nov 2025 14:38:11 +0100 Subject: [PATCH 054/113] refactored clothingPicker.js to use if/else control flow instead of nested ternary operators --- .../week-2/clothingPicker.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/courses/foundation/intro-to-javascript/week-2/clothingPicker.js b/courses/foundation/intro-to-javascript/week-2/clothingPicker.js index 17571254b..30085bf9f 100644 --- a/courses/foundation/intro-to-javascript/week-2/clothingPicker.js +++ b/courses/foundation/intro-to-javascript/week-2/clothingPicker.js @@ -1,8 +1,15 @@ function clothingPicker(temp) { - return temp >= 20 ? "T-Shirt" : - temp >= 15 ? "Sweater" : - temp >= 10 ? "Coat" : - temp >= 0 ? "Puffer jacket" : - temp < 0 ? "Slippers and pajamas" : - "Invalid temperature entered" ; + if (temp >= 20) { + return "T-Shirt"; + } else if (temp >= 15) { + return "Sweater"; + } else if (temp >= 10) { + return "Coat"; + } else if (temp >= 0) { + return "Puffer jacket"; + } else if (temp < 0) { + return "Slippers and pajamas"; + } else { + return "Invalid temperature entered"; + } } \ No newline at end of file From 64e4462414789e02795a18ed2a8877fc4c4fb767 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 12 Nov 2025 14:56:37 +0100 Subject: [PATCH 055/113] simplified getWeekday.js --- .../intro-to-javascript/week-2/getWeekday.js | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/courses/foundation/intro-to-javascript/week-2/getWeekday.js b/courses/foundation/intro-to-javascript/week-2/getWeekday.js index f8141a615..ad9ecf985 100644 --- a/courses/foundation/intro-to-javascript/week-2/getWeekday.js +++ b/courses/foundation/intro-to-javascript/week-2/getWeekday.js @@ -1,15 +1,16 @@ -const weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday","Thursday", "Friday", "Saturday"] -const currentDate = new Date(); -const currentDay = currentDate.getDay(); +const weekdays = [ + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", +]; + +const currentDay = new Date().getDay(); function getWeekday(num) { - const difference = num % 7; - const currentWeekday = currentDay + difference; - if (num === 0) { - return "Today" - } else { - return currentWeekday > 6 ? - weekdays[currentWeekday - 7] : - weekdays[currentWeekday]; - }; -}; \ No newline at end of file + const targetDay = currentDay + num % 7; + return num === 0 ? "Today" : weekdays[targetDay]; +} \ No newline at end of file From 7fa17b1d65c1cdb9accae9630e858cb136c2ef01 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Wed, 12 Nov 2025 17:36:35 +0100 Subject: [PATCH 056/113] simplified candyHelper.js --- .../intro-to-javascript/week-2/candyHelper.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/courses/foundation/intro-to-javascript/week-2/candyHelper.js b/courses/foundation/intro-to-javascript/week-2/candyHelper.js index 1342e35e1..49af34b6f 100644 --- a/courses/foundation/intro-to-javascript/week-2/candyHelper.js +++ b/courses/foundation/intro-to-javascript/week-2/candyHelper.js @@ -2,14 +2,19 @@ const pricePerGram = { sweet: 0.5, chocolate: 0.7, toffee: 1.1, - "chewing-gum": 0.03 + chewingGum: 0.03 }; -const addCandy = (type, weight) => canBuyMoreCandy() ? boughtCandyPrices.push(pricePerGram[type] * weight) : console.log("Enough candy for you!"); - const boughtCandyPrices = []; -const calculateTotalSpent = () => boughtCandyPrices.length > 0 ? boughtCandyPrices.reduce((x, y) => x + y) : 0 ; - -const canBuyMoreCandy = () => amountToSpend > calculateTotalSpent(); +const amountToSpend = Math.random() * 100; -const amountToSpend = Math.random() * 100; \ No newline at end of file +function addCandy(type, weight) { + const totalSpent = boughtCandyPrices.length > 0 ? boughtCandyPrices.reduce((x, y) => x + y) : 0; + const price = pricePerGram[type] * weight; + if (totalSpent + price < amountToSpend) { + boughtCandyPrices.push(price); + console.log("You can buy more, so please do!"); + } else { + console.log("Enough candy for you!"); + } +} \ No newline at end of file From 2df7949f3012794dc588211365e2bdcf68aa31e1 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Thu, 13 Nov 2025 15:44:29 +0100 Subject: [PATCH 057/113] added itemArrayRemoval.js --- .../week-3/itemArrayRemoval.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-3/itemArrayRemoval.js diff --git a/courses/foundation/intro-to-javascript/week-3/itemArrayRemoval.js b/courses/foundation/intro-to-javascript/week-3/itemArrayRemoval.js new file mode 100644 index 000000000..0d0cc343e --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-3/itemArrayRemoval.js @@ -0,0 +1,20 @@ +const names = [ + "Peter", + "Ahmad", + "Yana", + "kristina", + "Rasmus", + "Samuel", + "Katrine", + "Tala", +]; +const nameToRemove = "Ahmad"; + +function removeName(nameToRemove) { + for (let i = 0; i < names.length; i++) { + if(names[i] === nameToRemove) names.splice(i, 1); + } +} + +removeName(nameToRemove); +console.log(names); // ['Peter', 'Yana', 'kristina', 'Rasmus', 'Samuel', 'Katrine', 'Tala'] \ No newline at end of file From 25f9f596068a09063655bfefe87cb0f65fb02a53 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Thu, 13 Nov 2025 17:38:08 +0100 Subject: [PATCH 058/113] added travelCalculator.js --- .../week-3/travelCalculator.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-3/travelCalculator.js diff --git a/courses/foundation/intro-to-javascript/week-3/travelCalculator.js b/courses/foundation/intro-to-javascript/week-3/travelCalculator.js new file mode 100644 index 000000000..c11677870 --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-3/travelCalculator.js @@ -0,0 +1,17 @@ +const travelInformation = { + speed: 50, + destinationDistance: 432, +}; + +const travelTime = calculateTravelTime(travelInformation); +console.log(travelTime); + +function calculateTravelTime(obj) { + const speed = obj.speed; + const distance = obj.destinationDistance; + const totalSeconds = Math.floor((distance / speed) * 3600); + const hours = Math.floor(totalSeconds / 3600); + const minutes = Math.floor((totalSeconds % 3600) / 60); + const seconds = totalSeconds - hours * 3600 - minutes * 60; + return `${hours} hours, ${minutes} minutes and ${seconds} seconds` +} \ No newline at end of file From 4b910db46ac351784597d0d3787477146da1a253 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Fri, 14 Nov 2025 11:29:30 +0100 Subject: [PATCH 059/113] added seriesDuration.js --- .../week-3/seriesDuration.js | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-3/seriesDuration.js diff --git a/courses/foundation/intro-to-javascript/week-3/seriesDuration.js b/courses/foundation/intro-to-javascript/week-3/seriesDuration.js new file mode 100644 index 000000000..9e0b37798 --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-3/seriesDuration.js @@ -0,0 +1,42 @@ +const seriesDurations = [ + { + title: "Game of thrones", + days: 3, + hours: 1, + minutes: 0, + }, + { + title: "Sopranos", + days: 3, + hours: 14, + minutes: 0, + }, + { + title: "The Wire", + days: 2, + hours: 12, + minutes: 0, + }, +]; + +function calculatePercentage(obj) { + const percentage = (((obj.hours + (obj.days * 24)) / (8760*80)) * 100); + return percentage.toFixed(3); +} + +function calculateTimeSpent(arr) { + const total = { + days: 0, + hours: 0, + minutes: 0 + }; + for (let i = 0; i < arr.length; i++) { + const series = seriesDurations[i]; + console.log(`${series.title} took ${calculatePercentage(series)}% of my life`) + total.days += series.days; + total.hours += series.hours; + } + console.log(`In total, that is ${calculatePercentage(total)}% of my life`); +} + +calculateTimeSpent(seriesDurations); \ No newline at end of file From 4d46f7e219f2009fb3603b68c13048ce11ea1262 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Fri, 14 Nov 2025 11:41:08 +0100 Subject: [PATCH 060/113] added NOnoN0nOYes.js --- .../intro-to-javascript/week-3/NOnoN0nOYes.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-3/NOnoN0nOYes.js diff --git a/courses/foundation/intro-to-javascript/week-3/NOnoN0nOYes.js b/courses/foundation/intro-to-javascript/week-3/NOnoN0nOYes.js new file mode 100644 index 000000000..354c591c0 --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-3/NOnoN0nOYes.js @@ -0,0 +1,22 @@ +const notes = []; + +function saveNote(content, id) { + notes.push({ + content: content, + id: id + }); +} + +function getNote(id) { + for (let i = 0; i < notes.length; i++) { + if (notes[i].id === id) return notes[i] + } + return "Invalid ID entered" +} + +function logOutNotesFormatted() { + for (let i = 0; i < notes.length; i++) { + const note = notes[i]; + console.log(`The note with id: ${note.id}, has the following note text: ${note.content}`); + } +} \ No newline at end of file From 90227235fd1cfd05006f83831645b828df2a12d9 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Fri, 14 Nov 2025 14:47:57 +0100 Subject: [PATCH 061/113] added CactusIO-interactive.js --- .../week-3/CactusIO-interactive.js | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-3/CactusIO-interactive.js diff --git a/courses/foundation/intro-to-javascript/week-3/CactusIO-interactive.js b/courses/foundation/intro-to-javascript/week-3/CactusIO-interactive.js new file mode 100644 index 000000000..fe0ce50e4 --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-3/CactusIO-interactive.js @@ -0,0 +1,30 @@ +const activities = []; +const limit = 60; + + +function getCurrentDate() { + const current = new Date; + const day = current.getDate(); + const month = current.getMonth(); + const year = current.getFullYear(); + return `${day}/${month}-${year}` +} + +function addActivity(activity, duration) { + activities.push({ + date: getCurrentDate(), + activity: activity, + duration: duration + }); +} + +function showStatus(activities) { + let totalMinutes = 0; + const length = activities.length; + for (let i = 0; i < length; i++) { + totalMinutes += activities[i].duration; + } + if (totalMinutes > limit) return "You have reached your limit, no more smartphoning for you!"; + // NOTE: instructions unclear as to whether or not this function should return or log this result + return length > 0 ? `You have added ${length} activities. They amount to ${totalMinutes} min. of usage` : "Add some activities before calling showStatus"; +} \ No newline at end of file From ef5d573e4136c2e4f83b397b4ff39bf5f638d3ea Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 16 Nov 2025 12:22:34 +0100 Subject: [PATCH 062/113] improved variable naming --- .../foundation/intro-to-javascript/week-2/candyHelper.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/courses/foundation/intro-to-javascript/week-2/candyHelper.js b/courses/foundation/intro-to-javascript/week-2/candyHelper.js index 49af34b6f..3f6a38321 100644 --- a/courses/foundation/intro-to-javascript/week-2/candyHelper.js +++ b/courses/foundation/intro-to-javascript/week-2/candyHelper.js @@ -8,11 +8,11 @@ const pricePerGram = { const boughtCandyPrices = []; const amountToSpend = Math.random() * 100; -function addCandy(type, weight) { +function addCandy(candyType, grams) { const totalSpent = boughtCandyPrices.length > 0 ? boughtCandyPrices.reduce((x, y) => x + y) : 0; - const price = pricePerGram[type] * weight; - if (totalSpent + price < amountToSpend) { - boughtCandyPrices.push(price); + const candyPrice = pricePerGram[candyType] * grams; + if (totalSpent + candyPrice < amountToSpend) { + boughtCandyPrices.push(candyPrice); console.log("You can buy more, so please do!"); } else { console.log("Enough candy for you!"); From 729df3aa432e81bc68d3baf8d8a0475a1c5a95b1 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 16 Nov 2025 12:43:31 +0100 Subject: [PATCH 063/113] added jobMatching1.js --- .../intro-to-javascript/week-3/bonus-assignments/kata.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-3/bonus-assignments/kata.js diff --git a/courses/foundation/intro-to-javascript/week-3/bonus-assignments/kata.js b/courses/foundation/intro-to-javascript/week-3/bonus-assignments/kata.js new file mode 100644 index 000000000..2621f46bd --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-3/bonus-assignments/kata.js @@ -0,0 +1,7 @@ +function match(candidate, job) { + if (!candidate.minSalary || !job.maxSalary) { + throw Error(); + } else { + return candidate.minSalary * 0.9 <= job.maxSalary; + } +} \ No newline at end of file From 8d960636d4e5afd1ff7ced24cd918b102a469da6 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 16 Nov 2025 13:32:26 +0100 Subject: [PATCH 064/113] changed kata.js to arrayPractice.js --- .../week-3/in-class/arrayPractice.js | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-3/in-class/arrayPractice.js diff --git a/courses/foundation/intro-to-javascript/week-3/in-class/arrayPractice.js b/courses/foundation/intro-to-javascript/week-3/in-class/arrayPractice.js new file mode 100644 index 000000000..ddd90d8ba --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-3/in-class/arrayPractice.js @@ -0,0 +1,22 @@ +fruits = ["apple", "banana", "pear"] + +const addAtBeginningOfArray = (value, arr) => { + const result = [value]; + for (let i = 0; i < arr.length; i++) { + result.push(arr[i]); + } + return result +} + +const addAtBeginningOfArrayAndModify = (value) => { + for (let i = fruits.length-1; i <= 0; i--) { + fruits[i + 1] = arr[i]; + } + fruits[0] = value; + return fruits +} + + +console.log(addAtBeginningOfArray("lychee", fruits)); +addAtBeginningOfArrayAndModify("cherry"); +console.log(fruits); \ No newline at end of file From 01ff2c330c9e82ba982237b526966b66d3992fad Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 16 Nov 2025 13:33:27 +0100 Subject: [PATCH 065/113] replaced kata.js with jobMatching.js --- .../week-3/bonus-assignments/jobMatching1.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-3/bonus-assignments/jobMatching1.js diff --git a/courses/foundation/intro-to-javascript/week-3/bonus-assignments/jobMatching1.js b/courses/foundation/intro-to-javascript/week-3/bonus-assignments/jobMatching1.js new file mode 100644 index 000000000..2621f46bd --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-3/bonus-assignments/jobMatching1.js @@ -0,0 +1,7 @@ +function match(candidate, job) { + if (!candidate.minSalary || !job.maxSalary) { + throw Error(); + } else { + return candidate.minSalary * 0.9 <= job.maxSalary; + } +} \ No newline at end of file From 6421f540be8d9430a8136df41fc3a280caf468fa Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 16 Nov 2025 20:57:13 +0100 Subject: [PATCH 066/113] added favourites to note taker --- .../intro-to-javascript/week-3/NOnoN0nOYes.js | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/courses/foundation/intro-to-javascript/week-3/NOnoN0nOYes.js b/courses/foundation/intro-to-javascript/week-3/NOnoN0nOYes.js index 354c591c0..b27fec315 100644 --- a/courses/foundation/intro-to-javascript/week-3/NOnoN0nOYes.js +++ b/courses/foundation/intro-to-javascript/week-3/NOnoN0nOYes.js @@ -1,9 +1,9 @@ const notes = []; -function saveNote(content, id) { +function saveNote(content, id, favourite) { notes.push({ content: content, - id: id + id: id, }); } @@ -14,9 +14,27 @@ function getNote(id) { return "Invalid ID entered" } +function favouriteNote(id) { + for (let i = 0; i < notes.length; i++) { + if (notes[i].id === id) { + notes[i].favourite = true; + break; + } + } +} + function logOutNotesFormatted() { for (let i = 0; i < notes.length; i++) { const note = notes[i]; console.log(`The note with id: ${note.id}, has the following note text: ${note.content}`); } +} + +function logOutFavouritesFormatted() { + for (let i = 0; i < notes.length; i++) { + const note = notes[i]; + if (note.favourite) { + console.log(`The note with id: ${note.id}, has the following note text: ${note.content}`); + } + } } \ No newline at end of file From e807aebf5c093cc55b948c01f89f5a548aa0c326 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 16 Nov 2025 21:10:01 +0100 Subject: [PATCH 067/113] added jobMatching2.js --- .../week-3/bonus-assignments/jobMatching2.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-3/bonus-assignments/jobMatching2.js diff --git a/courses/foundation/intro-to-javascript/week-3/bonus-assignments/jobMatching2.js b/courses/foundation/intro-to-javascript/week-3/bonus-assignments/jobMatching2.js new file mode 100644 index 000000000..ddde6afd2 --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-3/bonus-assignments/jobMatching2.js @@ -0,0 +1,28 @@ +function matchEquity(candidate, job) { + if (candidate.desiresEquity && job.equityMax > 0) { + return true + } else if (!candidate.desiresEquity) { + return true + } else { + return false + } +} + +function matchLocation(candidate, job) { + const locations = [...candidate.desiredLocations,candidate.currentLocation]; + for (let i = 0; i < locations.length; i++) { + if (job.locations.includes(locations[i])) return true + } + return false +} + +function match(job, candidates) { + const matches = []; + for (let i = 0; i < candidates.length; i++) { + if (matchEquity(candidates[i], job) + && matchLocation(candidates[i], job)) { + matches.push(candidates[i]); + } + } + return matches +} \ No newline at end of file From fae66a6947f730b5f2290a97231465dbd0054e45 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 16 Nov 2025 21:11:06 +0100 Subject: [PATCH 068/113] added unfinished-loop.js --- .../week-3/bonus-assignments/unfinished-loop.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 courses/foundation/intro-to-javascript/week-3/bonus-assignments/unfinished-loop.js diff --git a/courses/foundation/intro-to-javascript/week-3/bonus-assignments/unfinished-loop.js b/courses/foundation/intro-to-javascript/week-3/bonus-assignments/unfinished-loop.js new file mode 100644 index 000000000..077d1ea76 --- /dev/null +++ b/courses/foundation/intro-to-javascript/week-3/bonus-assignments/unfinished-loop.js @@ -0,0 +1,7 @@ +function createArray(number) { + const newArray = []; + for (let counter = 1; counter <= number; counter++) { + newArray.push(counter); + } + return newArray; +} \ No newline at end of file From b3c32f4021c050d4fdb5d272fa1a801a7810ceaf Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sat, 22 Nov 2025 13:07:41 +0100 Subject: [PATCH 069/113] refactored code after review --- .../week-3/CactusIO-interactive.js | 19 +++++++++++++++---- .../intro-to-javascript/week-3/NOnoN0nOYes.js | 2 +- .../week-3/seriesDuration.js | 4 +++- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/courses/foundation/intro-to-javascript/week-3/CactusIO-interactive.js b/courses/foundation/intro-to-javascript/week-3/CactusIO-interactive.js index fe0ce50e4..6970c454a 100644 --- a/courses/foundation/intro-to-javascript/week-3/CactusIO-interactive.js +++ b/courses/foundation/intro-to-javascript/week-3/CactusIO-interactive.js @@ -19,12 +19,23 @@ function addActivity(activity, duration) { } function showStatus(activities) { - let totalMinutes = 0; const length = activities.length; + if (length < 1) return "Add some activities before calling showStatus."; + let totalMinutes = 0; for (let i = 0; i < length; i++) { totalMinutes += activities[i].duration; } - if (totalMinutes > limit) return "You have reached your limit, no more smartphoning for you!"; + if (totalMinutes > limit) return "You have reached your limit, no more smartphoning for you!"; // NOTE: instructions unclear as to whether or not this function should return or log this result - return length > 0 ? `You have added ${length} activities. They amount to ${totalMinutes} min. of usage` : "Add some activities before calling showStatus"; -} \ No newline at end of file + return activities.length > 1 ? + `You have added ${length} activities. They amount to ${totalMinutes} minutes of usage.` : + `You have added 1 activity. It amounts to ${totalMinutes} minutes of usage.`; +} + +console.log(showStatus(activities)); +addActivity("coding", 23) +console.log(showStatus(activities)); +addActivity("napping", 27) +console.log(showStatus(activities)); +addActivity("making tea", 15); +console.log(showStatus(activities)); diff --git a/courses/foundation/intro-to-javascript/week-3/NOnoN0nOYes.js b/courses/foundation/intro-to-javascript/week-3/NOnoN0nOYes.js index b27fec315..8889e3427 100644 --- a/courses/foundation/intro-to-javascript/week-3/NOnoN0nOYes.js +++ b/courses/foundation/intro-to-javascript/week-3/NOnoN0nOYes.js @@ -1,6 +1,6 @@ const notes = []; -function saveNote(content, id, favourite) { +function saveNote(content, id) { notes.push({ content: content, id: id, diff --git a/courses/foundation/intro-to-javascript/week-3/seriesDuration.js b/courses/foundation/intro-to-javascript/week-3/seriesDuration.js index 9e0b37798..76af096f9 100644 --- a/courses/foundation/intro-to-javascript/week-3/seriesDuration.js +++ b/courses/foundation/intro-to-javascript/week-3/seriesDuration.js @@ -20,7 +20,9 @@ const seriesDurations = [ ]; function calculatePercentage(obj) { - const percentage = (((obj.hours + (obj.days * 24)) / (8760*80)) * 100); + const totalHoursWatched = obj.hours + (obj.days * 24); + const hoursInAYear = 8760*80; + const percentage = ((totalHoursWatched / hoursInAYear) * 100); return percentage.toFixed(3); } From fcbc43b508b38dc8bc7e1dbc827d3774f8728086 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sat, 22 Nov 2025 13:08:55 +0100 Subject: [PATCH 070/113] removed leftover console.log tests --- .../intro-to-javascript/week-3/CactusIO-interactive.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/courses/foundation/intro-to-javascript/week-3/CactusIO-interactive.js b/courses/foundation/intro-to-javascript/week-3/CactusIO-interactive.js index 6970c454a..3cd001d00 100644 --- a/courses/foundation/intro-to-javascript/week-3/CactusIO-interactive.js +++ b/courses/foundation/intro-to-javascript/week-3/CactusIO-interactive.js @@ -30,12 +30,4 @@ function showStatus(activities) { return activities.length > 1 ? `You have added ${length} activities. They amount to ${totalMinutes} minutes of usage.` : `You have added 1 activity. It amounts to ${totalMinutes} minutes of usage.`; -} - -console.log(showStatus(activities)); -addActivity("coding", 23) -console.log(showStatus(activities)); -addActivity("napping", 27) -console.log(showStatus(activities)); -addActivity("making tea", 15); -console.log(showStatus(activities)); +} \ No newline at end of file From 7c9c4e6394d5f743098de01aba12d37dca8c6072 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 5 Jan 2026 15:57:56 +0100 Subject: [PATCH 071/113] added kata solutions --- .../assignments/codewars-katas.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 courses/foundation/intro-to-frontend/assignments/codewars-katas.js diff --git a/courses/foundation/intro-to-frontend/assignments/codewars-katas.js b/courses/foundation/intro-to-frontend/assignments/codewars-katas.js new file mode 100644 index 000000000..43e07ff00 --- /dev/null +++ b/courses/foundation/intro-to-frontend/assignments/codewars-katas.js @@ -0,0 +1,29 @@ +// remove first and last character +function removeChar(str){ +if (str.length < 3) { + return ""; +} else { + return str.slice(1, str.length-1); +} +}; + +// counting sheep... +function countSheeps(sheep) { + let count = 0; + for (let i = 0; i < sheep.length; i++) { + if (sheep[i] === true) count++; + } + return count; +} + +// string ends with +const solution = (str, ending) => str.slice(str.length - ending.length) === ending; + +// odd or even? +function oddOrEven(array) { + if (array.length === 0 || array.reduce((x, y) => x + y) % 2 === 0) { + return "even"; + } else { + return "odd"; + } +} \ No newline at end of file From b8bf6b2d2ef980802e3761fdef331ca0b487b998 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 5 Jan 2026 17:06:39 +0100 Subject: [PATCH 072/113] added index.html to HogwartsHouseGenerator --- .../HogwartsHouseGenerator/index.html | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html diff --git a/courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html b/courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html new file mode 100644 index 000000000..0e2746d00 --- /dev/null +++ b/courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html @@ -0,0 +1,87 @@ + + + + + + + +
    +

    The Sorting Hat

    + + + + + + + +
    +
    + +

    +
    + + \ No newline at end of file From 7649ccb3577ccdc2f9a2abfb41d4d57ef8de5a9e Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 5 Jan 2026 17:26:30 +0100 Subject: [PATCH 073/113] added HYFbay files (all logic is contained within main.js, including list creation) --- courses/foundation/intro-to-frontend/HYFBay/main.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/courses/foundation/intro-to-frontend/HYFBay/main.js b/courses/foundation/intro-to-frontend/HYFBay/main.js index 00111ae11..e85a65fde 100644 --- a/courses/foundation/intro-to-frontend/HYFBay/main.js +++ b/courses/foundation/intro-to-frontend/HYFBay/main.js @@ -5,7 +5,14 @@ console.log(products); // This should create the ul and the li's with the individual products details function renderProducts(products) { - // your code goes here + document.body.innerHTML = ""; + const list = document.createElement("ul"); + for (let i = 0; i < products.length; i++) { + const item = document.createElement("li"); + item.innerHTML = "" + products[i].name + "" + "
    " + products[i].price + " kr.
    rating: " + products[i].rating; + list.appendChild(item); + } + document.body.appendChild(list); } renderProducts(products); From cd120d0e0bef1f48705b32f364869d3f2a6c077a Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 5 Jan 2026 22:31:48 +0100 Subject: [PATCH 074/113] refactored renderProducts() to display data in table form; added functions to format price and rating; applied styling --- .../intro-to-frontend/HYFBay/index.html | 26 +++++++--- .../intro-to-frontend/HYFBay/main.css | 46 +++++++++++++++++ .../intro-to-frontend/HYFBay/main.js | 50 +++++++++++++++---- 3 files changed, 106 insertions(+), 16 deletions(-) diff --git a/courses/foundation/intro-to-frontend/HYFBay/index.html b/courses/foundation/intro-to-frontend/HYFBay/index.html index 07f60fe48..bf6d28c7e 100644 --- a/courses/foundation/intro-to-frontend/HYFBay/index.html +++ b/courses/foundation/intro-to-frontend/HYFBay/index.html @@ -1,14 +1,26 @@ HyfBay - + - + + -
    +

    HYFBay

    + + + + + + + + + + +
    ItemPriceRating
    +
    + +
    - + \ No newline at end of file diff --git a/courses/foundation/intro-to-frontend/HYFBay/main.css b/courses/foundation/intro-to-frontend/HYFBay/main.css index 9f6b12f10..fd49ca85f 100644 --- a/courses/foundation/intro-to-frontend/HYFBay/main.css +++ b/courses/foundation/intro-to-frontend/HYFBay/main.css @@ -1,6 +1,7 @@ body { font-family: "Open Sans", sans-serif; background-color: #f9fbfd; + justify-content: center; } * { @@ -11,6 +12,7 @@ body, h1, h2 { margin: 0; + text-align: center; } ul { @@ -18,3 +20,47 @@ ul { margin: 0; padding: 0; } + +table { + padding: 40px; + width: 375px; + margin: 0 auto; + table-layout: fixed; + border-collapse: collapse; +} + +th, +td, +tr { + text-align: left; + padding-top: 5px; + padding-bottom: 5px; +} + +th { + background-color: green; + color: white; +} + +tr { + text-align: left; +} + +tr:nth-child(even) { + background-color: #d8d8d8; +} + +th:nth-child(1), td:nth-child(1) { + width: 50%; + padding-left: 5px; +} +th:nth-child(2) { + width: 25%; +} +th:nth-child(3) { + width: 25%; +} + +.stars { + color: rgb(255, 174, 0); +} diff --git a/courses/foundation/intro-to-frontend/HYFBay/main.js b/courses/foundation/intro-to-frontend/HYFBay/main.js index e85a65fde..64ca4d6b3 100644 --- a/courses/foundation/intro-to-frontend/HYFBay/main.js +++ b/courses/foundation/intro-to-frontend/HYFBay/main.js @@ -3,16 +3,48 @@ console.log("Script loaded"); const products = getAvailableProducts(); console.log(products); -// This should create the ul and the li's with the individual products details -function renderProducts(products) { - document.body.innerHTML = ""; - const list = document.createElement("ul"); +const renderProducts = products => { + const tbody = document.querySelector("tbody"); + tbody.innerHTML = ""; + for (let i = 0; i < products.length; i++) { - const item = document.createElement("li"); - item.innerHTML = "" + products[i].name + "" + "
    " + products[i].price + " kr.
    rating: " + products[i].rating; - list.appendChild(item); + const row = document.createElement("tr"); + + const name = document.createElement("td"); + name.innerHTML = "" + products[i].name + ""; + row.appendChild(name); + + const price = document.createElement("td"); + price.innerHTML = formatPrice(products[i].price) + " kr."; + row.appendChild(price); + + const rating = document.createElement("td"); + rating.innerHTML = formatRating(products[i].rating); + row.appendChild(rating); + + tbody.appendChild(row); + } +} + +// star: U+2605; half-star: U+2BE8 + +const formatPrice = number => { + return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); +} + +const formatRating = number => { + let formattedRating = "" + if (number % 2 === 0) { + for (let i = 0; i < number; i += 2) { + formattedRating = formattedRating + "★ "; + } + } else { + for (let i = 0; i < number-2; i += 2) { + formattedRating = formattedRating + "★ "; + } + formattedRating = formattedRating + "⯨ "; } - document.body.appendChild(list); + return '' + formattedRating + ''; } -renderProducts(products); +renderProducts(products); From b9c948637f1865f912d79364b5c5e6b72dd2c2ce Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 5 Jan 2026 22:37:52 +0100 Subject: [PATCH 075/113] removed length checking from name input --- .../intro-to-frontend/HogwartsHouseGenerator/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html b/courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html index 0e2746d00..c7790f5b9 100644 --- a/courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html +++ b/courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html @@ -40,7 +40,7 @@

    The Sorting Hat

    - + From 8ef0768150daa6d074778efc980ee04e6a1e0b1b Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 5 Jan 2026 22:43:32 +0100 Subject: [PATCH 076/113] refactored assignHouse() to display house names in bold --- .../intro-to-frontend/HogwartsHouseGenerator/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html b/courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html index c7790f5b9..f7f4b2536 100644 --- a/courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html +++ b/courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html @@ -66,7 +66,7 @@

    The Sorting Hat

    const assignHouse = () => { const name = document.getElementById("name").value; const house = houses[Math.floor(Math.random() * 4)]; - const message = name.length > 0 ? `${name} belongs in ${house},` : `You belong in ${house},`; + const message = name.length > 0 ? `${name} belongs in ${house},` : `You belong in ${house},`; document.getElementById("text").innerHTML = message; document.getElementById("crest").src = crestUrls[house]; switch (house) { From 30182cee150b5aa7a81f218eb7cc3dc99140c1ef Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 5 Jan 2026 22:47:26 +0100 Subject: [PATCH 077/113] created convenience variable for text to improve readability --- .../HogwartsHouseGenerator/index.html | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html b/courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html index f7f4b2536..0950f8c83 100644 --- a/courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html +++ b/courses/foundation/intro-to-frontend/HogwartsHouseGenerator/index.html @@ -67,20 +67,21 @@

    The Sorting Hat

    const name = document.getElementById("name").value; const house = houses[Math.floor(Math.random() * 4)]; const message = name.length > 0 ? `${name} belongs in ${house},` : `You belong in ${house},`; - document.getElementById("text").innerHTML = message; + const text = document.getElementById("text"); + text.innerHTML = message; document.getElementById("crest").src = crestUrls[house]; switch (house) { case "Slytherin": - document.getElementById("text").innerHTML += "
    the house of cunning and ambition."; + text.innerHTML += "
    the house of cunning and ambition."; break; case "Hufflepuff": - document.getElementById("text").innerHTML += "
    the house of loyalty and patience."; + text.innerHTML += "
    the house of loyalty and patience."; break; case "Ravenclaw": - document.getElementById("text").innerHTML += "
    the house of learning and wisdom."; + text.innerHTML += "
    the house of learning and wisdom."; break; case "Gryffindor": - document.getElementById("text").innerHTML += "
    the house of daring and determination."; + text.innerHTML += "
    the house of daring and determination."; break; } } From d540a565ca3c8fa442f2d550dacdc2a0a9c5bdbc Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 5 Jan 2026 23:44:59 +0100 Subject: [PATCH 078/113] refactored formatPrice() to use the addition assignment operator --- courses/foundation/intro-to-frontend/HYFBay/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/courses/foundation/intro-to-frontend/HYFBay/main.js b/courses/foundation/intro-to-frontend/HYFBay/main.js index 64ca4d6b3..5c518d5e6 100644 --- a/courses/foundation/intro-to-frontend/HYFBay/main.js +++ b/courses/foundation/intro-to-frontend/HYFBay/main.js @@ -36,13 +36,13 @@ const formatRating = number => { let formattedRating = "" if (number % 2 === 0) { for (let i = 0; i < number; i += 2) { - formattedRating = formattedRating + "★ "; + formattedRating += "★ "; } } else { for (let i = 0; i < number-2; i += 2) { - formattedRating = formattedRating + "★ "; + formattedRating += "★ "; } - formattedRating = formattedRating + "⯨ "; + formattedRating += "⯨ "; } return '' + formattedRating + ''; } From 621e1a313b2d66dc3c6f21d3b143d2f2d4470d21 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:07:01 +0100 Subject: [PATCH 079/113] added teas data --- .../advanced-javascript/week1/data/teas.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/data/teas.js diff --git a/courses/backend/advanced-javascript/week1/data/teas.js b/courses/backend/advanced-javascript/week1/data/teas.js new file mode 100644 index 000000000..e7695b125 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/data/teas.js @@ -0,0 +1,23 @@ +// prettier-ignore +export const teas = [ + { id: 1, name: "Sencha", type: "green", origin: "Japan", pricePerGram: 0.12, caffeineLevel: "medium", organic: true, inStock: true, stockCount: 150 }, + { id: 2, name: "Earl Grey", type: "black", origin: "India", pricePerGram: 0.08, caffeineLevel: "high", organic: false, inStock: true, stockCount: 200 }, + { id: 3, name: "Dragon Well", type: "green", origin: "China", pricePerGram: 0.25, caffeineLevel: "medium", organic: true, inStock: true, stockCount: 45 }, + { id: 4, name: "Chamomile", type: "herbal", origin: "Egypt", pricePerGram: 0.10, caffeineLevel: "none", organic: true, inStock: true, stockCount: 180 }, + { id: 5, name: "Darjeeling", type: "black", origin: "India", pricePerGram: 0.18, caffeineLevel: "high", organic: false, inStock: true, stockCount: 90 }, + { id: 6, name: "Oolong", type: "oolong", origin: "Taiwan", pricePerGram: 0.22, caffeineLevel: "medium", organic: true, inStock: true, stockCount: 60 }, + { id: 7, name: "Peppermint", type: "herbal", origin: "USA", pricePerGram: 0.08, caffeineLevel: "none", organic: true, inStock: true, stockCount: 220 }, + { id: 8, name: "Matcha", type: "green", origin: "Japan", pricePerGram: 0.45, caffeineLevel: "high", organic: true, inStock: true, stockCount: 30 }, + { id: 9, name: "Assam", type: "black", origin: "India", pricePerGram: 0.09, caffeineLevel: "high", organic: false, inStock: true, stockCount: 175 }, + { id: 10, name: "White Peony", type: "white", origin: "China", pricePerGram: 0.30, caffeineLevel: "low", organic: true, inStock: true, stockCount: 55 }, + { id: 11, name: "Rooibos", type: "herbal", origin: "South Africa", pricePerGram: 0.11, caffeineLevel: "none", organic: true, inStock: true, stockCount: 140 }, + { id: 12, name: "Gyokuro", type: "green", origin: "Japan", pricePerGram: 0.56, caffeineLevel: "high", organic: false, inStock: false, stockCount: 0 }, + { id: 13, name: "Lapsang Souchong", type: "black", origin: "China", pricePerGram: 0.15, caffeineLevel: "medium", organic: false, inStock: true, stockCount: 85 }, + { id: 14, name: "Silver Needle", type: "white", origin: "China", pricePerGram: 0.50, caffeineLevel: "low", organic: true, inStock: true, stockCount: 25 }, + { id: 15, name: "Genmaicha", type: "green", origin: "Japan", pricePerGram: 0.10, caffeineLevel: "low", organic: false, inStock: true, stockCount: 110 }, + { id: 16, name: "Tie Guan Yin", type: "oolong", origin: "China", pricePerGram: 0.30, caffeineLevel: "medium", organic: true, inStock: true, stockCount: 40 }, + { id: 17, name: "English Breakfast", type: "black", origin: "Sri Lanka", pricePerGram: 0.06, caffeineLevel: "high", organic: false, inStock: true, stockCount: 250 }, + { id: 18, name: "Hibiscus", type: "herbal", origin: "Sudan", pricePerGram: 0.09, caffeineLevel: "none", organic: true, inStock: true, stockCount: 95 }, + { id: 19, name: "Pu-erh", type: "black", origin: "China", pricePerGram: 0.35, caffeineLevel: "medium", organic: false, inStock: false, stockCount: 0 }, + { id: 20, name: "Jasmine Pearl", type: "green", origin: "China", pricePerGram: 0.32, caffeineLevel: "medium", organic: true, inStock: true, stockCount: 70 } +]; \ No newline at end of file From 81ff64812d0025bb6bbe99687f5d0ab25bc79885 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:10:32 +0100 Subject: [PATCH 080/113] added exercise 1 --- courses/backend/advanced-javascript/week1/exercise-1.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/exercise-1.js diff --git a/courses/backend/advanced-javascript/week1/exercise-1.js b/courses/backend/advanced-javascript/week1/exercise-1.js new file mode 100644 index 000000000..3295d9e59 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/exercise-1.js @@ -0,0 +1,3 @@ +import { teas } from "./data/teas.js"; + +teas.forEach(tea => console.log(tea.name)); \ No newline at end of file From 718b381cbb64b13aede1a6f3b4f458394fbba6b9 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:12:21 +0100 Subject: [PATCH 081/113] added exercise 2 --- courses/backend/advanced-javascript/week1/exercise-2.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/exercise-2.js diff --git a/courses/backend/advanced-javascript/week1/exercise-2.js b/courses/backend/advanced-javascript/week1/exercise-2.js new file mode 100644 index 000000000..febb682c8 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/exercise-2.js @@ -0,0 +1,3 @@ +import { teas } from "./data/teas.js"; + +teas.forEach(tea => console.log(`${tea.name} (${tea.origin})`)); \ No newline at end of file From c2ad27c00ba0c6db945bb0d6ccb45561bd016290 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:15:01 +0100 Subject: [PATCH 082/113] added exercise 3 --- courses/backend/advanced-javascript/week1/exercise-3.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/exercise-3.js diff --git a/courses/backend/advanced-javascript/week1/exercise-3.js b/courses/backend/advanced-javascript/week1/exercise-3.js new file mode 100644 index 000000000..f5c604ba6 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/exercise-3.js @@ -0,0 +1,7 @@ +import { teas } from "./data/teas.js"; + +let organicCount = 0; + +teas.forEach(tea => {if (tea.organic) organicCount++}); + +console.log(organicCount); \ No newline at end of file From 80916816ffcddc5a7d6c083a51e2fdca26d9814a Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:16:40 +0100 Subject: [PATCH 083/113] added exercise 4 --- courses/backend/advanced-javascript/week1/exercise-4.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/exercise-4.js diff --git a/courses/backend/advanced-javascript/week1/exercise-4.js b/courses/backend/advanced-javascript/week1/exercise-4.js new file mode 100644 index 000000000..db1152344 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/exercise-4.js @@ -0,0 +1,3 @@ +import { teas } from "./data/teas.js"; + +const teaNames = teas.map(tea => tea.name); \ No newline at end of file From 8199df0e6997d23e2ed83495c9c7bfb8fd323f74 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:24:09 +0100 Subject: [PATCH 084/113] added exercise 5 --- courses/backend/advanced-javascript/week1/exercise-5.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/exercise-5.js diff --git a/courses/backend/advanced-javascript/week1/exercise-5.js b/courses/backend/advanced-javascript/week1/exercise-5.js new file mode 100644 index 000000000..1f0fa215e --- /dev/null +++ b/courses/backend/advanced-javascript/week1/exercise-5.js @@ -0,0 +1,5 @@ +import { teas } from "./data/teas.js"; + +const teaPrices = teas.map(tea => tea.pricePerGram * 100); + +console.log(teaPrices); \ No newline at end of file From 18099017ea9137cdc6f574f6e082ceeb472d1977 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:28:34 +0100 Subject: [PATCH 085/113] added exercise 6 --- courses/backend/advanced-javascript/week1/exercise-6.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/exercise-6.js diff --git a/courses/backend/advanced-javascript/week1/exercise-6.js b/courses/backend/advanced-javascript/week1/exercise-6.js new file mode 100644 index 000000000..c1471d620 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/exercise-6.js @@ -0,0 +1,5 @@ +import { teas } from "./data/teas.js"; + +const displayStrings = teas.map(tea => `${tea.name} - ${tea.pricePerGram * 100}/100g`); +console.log(teas) +console.log(displayStrings); \ No newline at end of file From bc82241e52875a56b526afdcbfc3c08d024a6f2e Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:29:00 +0100 Subject: [PATCH 086/113] completed exercise 6 --- courses/backend/advanced-javascript/week1/exercise-6.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/courses/backend/advanced-javascript/week1/exercise-6.js b/courses/backend/advanced-javascript/week1/exercise-6.js index c1471d620..77b04a73b 100644 --- a/courses/backend/advanced-javascript/week1/exercise-6.js +++ b/courses/backend/advanced-javascript/week1/exercise-6.js @@ -1,5 +1,5 @@ import { teas } from "./data/teas.js"; -const displayStrings = teas.map(tea => `${tea.name} - ${tea.pricePerGram * 100}/100g`); -console.log(teas) +const displayStrings = teas.map(tea => `${tea.name} - ${tea.pricePerGram * 100} DKK/100g`); + console.log(displayStrings); \ No newline at end of file From 8e03de2a8ce355324ee53d32052532c6e20a71bc Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:30:48 +0100 Subject: [PATCH 087/113] added exercise 7 --- courses/backend/advanced-javascript/week1/exercise-7.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/exercise-7.js diff --git a/courses/backend/advanced-javascript/week1/exercise-7.js b/courses/backend/advanced-javascript/week1/exercise-7.js new file mode 100644 index 000000000..5ef5dc121 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/exercise-7.js @@ -0,0 +1,3 @@ +import { teas } from "./data/teas.js"; + +const organicTeas = teas.filter(tea => tea.organic); \ No newline at end of file From 5b69d5dbda073315f597fb0b5c01557a01f57be8 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:31:59 +0100 Subject: [PATCH 088/113] added exercise 8 --- courses/backend/advanced-javascript/week1/exercise-8.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/exercise-8.js diff --git a/courses/backend/advanced-javascript/week1/exercise-8.js b/courses/backend/advanced-javascript/week1/exercise-8.js new file mode 100644 index 000000000..8b2b88202 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/exercise-8.js @@ -0,0 +1,3 @@ +import { teas } from "./data/teas.js"; + +const japaneseTeas = teas.filter(tea => tea.origin === "Japan"); \ No newline at end of file From 31f1eb0240fc7ef10ebcd20ee89a5a44ae8799fe Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:34:29 +0100 Subject: [PATCH 089/113] added exercise 9 --- courses/backend/advanced-javascript/week1/exercise-9.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/exercise-9.js diff --git a/courses/backend/advanced-javascript/week1/exercise-9.js b/courses/backend/advanced-javascript/week1/exercise-9.js new file mode 100644 index 000000000..21ef3b736 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/exercise-9.js @@ -0,0 +1,3 @@ +import { teas } from "./data/teas.js"; + +const highCaffeineTeas = teas.filter(tea => tea.caffeineLevel === "high"); \ No newline at end of file From d41cbbc50164cf7ac66deb3ef12df905784963b7 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:36:46 +0100 Subject: [PATCH 090/113] added exercise 10 --- courses/backend/advanced-javascript/week1/exercise-10.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/exercise-10.js diff --git a/courses/backend/advanced-javascript/week1/exercise-10.js b/courses/backend/advanced-javascript/week1/exercise-10.js new file mode 100644 index 000000000..9d11419dc --- /dev/null +++ b/courses/backend/advanced-javascript/week1/exercise-10.js @@ -0,0 +1,3 @@ +import { teas } from "./data/teas.js"; + +const organicTeasInStock = teas.filter(tea => tea.inStock).filter(tea => tea.organic); \ No newline at end of file From cf88ae091f044324f06ec9f9b84df8ab33b2556f Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:38:42 +0100 Subject: [PATCH 091/113] added exercise 11 --- courses/backend/advanced-javascript/week1/exercise-11.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/exercise-11.js diff --git a/courses/backend/advanced-javascript/week1/exercise-11.js b/courses/backend/advanced-javascript/week1/exercise-11.js new file mode 100644 index 000000000..f6e706224 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/exercise-11.js @@ -0,0 +1,3 @@ +import { teas } from "./data/teas.js"; + +const greenTeaNames = teas.filter(tea => tea.type === "green").map(tea => tea.name); \ No newline at end of file From 96c9305c8d31a8d59d2d7c8c1f02ec1789c0ff32 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:40:52 +0100 Subject: [PATCH 092/113] added exercise 12 --- courses/backend/advanced-javascript/week1/exercise-12.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/exercise-12.js diff --git a/courses/backend/advanced-javascript/week1/exercise-12.js b/courses/backend/advanced-javascript/week1/exercise-12.js new file mode 100644 index 000000000..0da151a3c --- /dev/null +++ b/courses/backend/advanced-javascript/week1/exercise-12.js @@ -0,0 +1,3 @@ +import { teas } from "./data/teas.js"; + +const organicTeaStrings = teas.filter(tea => tea.organic).map(tea => `${tea.name} - ${tea.pricePerGram * 100} DKK/100g`); \ No newline at end of file From 2ac3d556100215c0594e53473afe5f1b4be6a892 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:42:35 +0100 Subject: [PATCH 093/113] added exercise 12 --- courses/backend/advanced-javascript/week1/exercise-12.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/courses/backend/advanced-javascript/week1/exercise-12.js b/courses/backend/advanced-javascript/week1/exercise-12.js index 0da151a3c..9e6ad364b 100644 --- a/courses/backend/advanced-javascript/week1/exercise-12.js +++ b/courses/backend/advanced-javascript/week1/exercise-12.js @@ -1,3 +1,3 @@ import { teas } from "./data/teas.js"; -const organicTeaStrings = teas.filter(tea => tea.organic).map(tea => `${tea.name} - ${tea.pricePerGram * 100} DKK/100g`); \ No newline at end of file +const japaneseTeasByPrice = teas.filter(tea => tea.origin === "Japan").sort((a, b) => a.pricePerGram - b.pricePerGram); \ No newline at end of file From 9627262718d5412fd248b0814847602b0dc63ffe Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:43:55 +0100 Subject: [PATCH 094/113] fixed exercise 12 --- courses/backend/advanced-javascript/week1/exercise-12.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/courses/backend/advanced-javascript/week1/exercise-12.js b/courses/backend/advanced-javascript/week1/exercise-12.js index 9e6ad364b..0da151a3c 100644 --- a/courses/backend/advanced-javascript/week1/exercise-12.js +++ b/courses/backend/advanced-javascript/week1/exercise-12.js @@ -1,3 +1,3 @@ import { teas } from "./data/teas.js"; -const japaneseTeasByPrice = teas.filter(tea => tea.origin === "Japan").sort((a, b) => a.pricePerGram - b.pricePerGram); \ No newline at end of file +const organicTeaStrings = teas.filter(tea => tea.organic).map(tea => `${tea.name} - ${tea.pricePerGram * 100} DKK/100g`); \ No newline at end of file From ea1f26afa862dd93c8df02db0e4cb42e052a8060 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 13:44:35 +0100 Subject: [PATCH 095/113] added exercise 13 --- courses/backend/advanced-javascript/week1/exercise-13.js | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/exercise-13.js diff --git a/courses/backend/advanced-javascript/week1/exercise-13.js b/courses/backend/advanced-javascript/week1/exercise-13.js new file mode 100644 index 000000000..9e6ad364b --- /dev/null +++ b/courses/backend/advanced-javascript/week1/exercise-13.js @@ -0,0 +1,3 @@ +import { teas } from "./data/teas.js"; + +const japaneseTeasByPrice = teas.filter(tea => tea.origin === "Japan").sort((a, b) => a.pricePerGram - b.pricePerGram); \ No newline at end of file From 321d70d938d480fc1426c361e0743551cd5bdfc9 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 14:58:20 +0100 Subject: [PATCH 096/113] added exercise 17 --- .../advanced-javascript/week1/exercise-17.js | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/exercise-17.js diff --git a/courses/backend/advanced-javascript/week1/exercise-17.js b/courses/backend/advanced-javascript/week1/exercise-17.js new file mode 100644 index 000000000..fc2bce88e --- /dev/null +++ b/courses/backend/advanced-javascript/week1/exercise-17.js @@ -0,0 +1,25 @@ +// filterTeas(teas, { organic: true }); +// // Returns all organic teas + +// filterTeas(teas, { origin: "Japan" }); +// // Returns all Japanese teas + +// filterTeas(teas, { organic: true, origin: "Japan" }); +// // Returns organic Japanese teas + +// filterTeas(teas, { type: "green", inStock: true }); +// // Returns green teas that are in stock + +import { teas } from "./data/teas.js"; + +function filterTeas (teas, obj) { + const entries = Object.entries(obj); + entries.forEach((entry) => { + const key = entry[0]; + const value = entry[1]; + teas = teas.filter(tea => tea[key] === value); + }) + return teas; +} + +console.log(filterTeas(teas, { type: "green", inStock: true })); \ No newline at end of file From 5907c609135d63e768645703258bf3191581ece9 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 14:59:34 +0100 Subject: [PATCH 097/113] moved in-class exercises to their own folder --- .../week1/in-class/exercise-1.js | 3 +++ .../week1/in-class/exercise-10.js | 3 +++ .../week1/in-class/exercise-11.js | 3 +++ .../week1/in-class/exercise-12.js | 3 +++ .../week1/in-class/exercise-13.js | 3 +++ .../week1/in-class/exercise-17.js | 25 +++++++++++++++++++ .../week1/in-class/exercise-2.js | 3 +++ .../week1/in-class/exercise-3.js | 7 ++++++ .../week1/in-class/exercise-4.js | 3 +++ .../week1/in-class/exercise-5.js | 5 ++++ .../week1/in-class/exercise-6.js | 5 ++++ .../week1/in-class/exercise-7.js | 3 +++ .../week1/in-class/exercise-8.js | 3 +++ .../week1/in-class/exercise-9.js | 3 +++ 14 files changed, 72 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/in-class/exercise-1.js create mode 100644 courses/backend/advanced-javascript/week1/in-class/exercise-10.js create mode 100644 courses/backend/advanced-javascript/week1/in-class/exercise-11.js create mode 100644 courses/backend/advanced-javascript/week1/in-class/exercise-12.js create mode 100644 courses/backend/advanced-javascript/week1/in-class/exercise-13.js create mode 100644 courses/backend/advanced-javascript/week1/in-class/exercise-17.js create mode 100644 courses/backend/advanced-javascript/week1/in-class/exercise-2.js create mode 100644 courses/backend/advanced-javascript/week1/in-class/exercise-3.js create mode 100644 courses/backend/advanced-javascript/week1/in-class/exercise-4.js create mode 100644 courses/backend/advanced-javascript/week1/in-class/exercise-5.js create mode 100644 courses/backend/advanced-javascript/week1/in-class/exercise-6.js create mode 100644 courses/backend/advanced-javascript/week1/in-class/exercise-7.js create mode 100644 courses/backend/advanced-javascript/week1/in-class/exercise-8.js create mode 100644 courses/backend/advanced-javascript/week1/in-class/exercise-9.js diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-1.js b/courses/backend/advanced-javascript/week1/in-class/exercise-1.js new file mode 100644 index 000000000..dd188b8b7 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-1.js @@ -0,0 +1,3 @@ +import { teas } from "../data/teas.js"; + +teas.forEach(tea => console.log(tea.name)); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-10.js b/courses/backend/advanced-javascript/week1/in-class/exercise-10.js new file mode 100644 index 000000000..ddff41f12 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-10.js @@ -0,0 +1,3 @@ +import { teas } from "../data/teas.js"; + +const organicTeasInStock = teas.filter(tea => tea.inStock).filter(tea => tea.organic); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-11.js b/courses/backend/advanced-javascript/week1/in-class/exercise-11.js new file mode 100644 index 000000000..d4a7f4110 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-11.js @@ -0,0 +1,3 @@ +import { teas } from "../data/teas.js"; + +const greenTeaNames = teas.filter(tea => tea.type === "green").map(tea => tea.name); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-12.js b/courses/backend/advanced-javascript/week1/in-class/exercise-12.js new file mode 100644 index 000000000..1fc7a5b5d --- /dev/null +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-12.js @@ -0,0 +1,3 @@ +import { teas } from "../data/teas.js"; + +const organicTeaStrings = teas.filter(tea => tea.organic).map(tea => `${tea.name} - ${tea.pricePerGram * 100} DKK/100g`); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-13.js b/courses/backend/advanced-javascript/week1/in-class/exercise-13.js new file mode 100644 index 000000000..2952565de --- /dev/null +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-13.js @@ -0,0 +1,3 @@ +import { teas } from "../data/teas.js"; + +const japaneseTeasByPrice = teas.filter(tea => tea.origin === "Japan").sort((a, b) => a.pricePerGram - b.pricePerGram); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-17.js b/courses/backend/advanced-javascript/week1/in-class/exercise-17.js new file mode 100644 index 000000000..ce374c44c --- /dev/null +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-17.js @@ -0,0 +1,25 @@ +// filterTeas(teas, { organic: true }); +// // Returns all organic teas + +// filterTeas(teas, { origin: "Japan" }); +// // Returns all Japanese teas + +// filterTeas(teas, { organic: true, origin: "Japan" }); +// // Returns organic Japanese teas + +// filterTeas(teas, { type: "green", inStock: true }); +// // Returns green teas that are in stock + +import { teas } from "../data/teas.js"; + +function filterTeas (teas, obj) { + const entries = Object.entries(obj); + entries.forEach((entry) => { + const key = entry[0]; + const value = entry[1]; + teas = teas.filter(tea => tea[key] === value); + }) + return teas; +} + +console.log(filterTeas(teas, { type: "green", inStock: true })); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-2.js b/courses/backend/advanced-javascript/week1/in-class/exercise-2.js new file mode 100644 index 000000000..0d41697bc --- /dev/null +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-2.js @@ -0,0 +1,3 @@ +import { teas } from "../data/teas.js"; + +teas.forEach(tea => console.log(`${tea.name} (${tea.origin})`)); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-3.js b/courses/backend/advanced-javascript/week1/in-class/exercise-3.js new file mode 100644 index 000000000..8b3f8ca2b --- /dev/null +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-3.js @@ -0,0 +1,7 @@ +import { teas } from "../data/teas.js"; + +let organicCount = 0; + +teas.forEach(tea => {if (tea.organic) organicCount++}); + +console.log(organicCount); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-4.js b/courses/backend/advanced-javascript/week1/in-class/exercise-4.js new file mode 100644 index 000000000..6e3a12f35 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-4.js @@ -0,0 +1,3 @@ +import { teas } from "../data/teas.js"; + +const teaNames = teas.map(tea => tea.name); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-5.js b/courses/backend/advanced-javascript/week1/in-class/exercise-5.js new file mode 100644 index 000000000..85579d2b5 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-5.js @@ -0,0 +1,5 @@ +import { teas } from "../data/teas.js"; + +const teaPrices = teas.map(tea => tea.pricePerGram * 100); + +console.log(teaPrices); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-6.js b/courses/backend/advanced-javascript/week1/in-class/exercise-6.js new file mode 100644 index 000000000..07f561008 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-6.js @@ -0,0 +1,5 @@ +import { teas } from "../data/teas.js"; + +const displayStrings = teas.map(tea => `${tea.name} - ${tea.pricePerGram * 100} DKK/100g`); + +console.log(displayStrings); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-7.js b/courses/backend/advanced-javascript/week1/in-class/exercise-7.js new file mode 100644 index 000000000..148fdc166 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-7.js @@ -0,0 +1,3 @@ +import { teas } from "../data/teas.js"; + +const organicTeas = teas.filter(tea => tea.organic); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-8.js b/courses/backend/advanced-javascript/week1/in-class/exercise-8.js new file mode 100644 index 000000000..9177854a5 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-8.js @@ -0,0 +1,3 @@ +import { teas } from "../data/teas.js"; + +const japaneseTeas = teas.filter(tea => tea.origin === "Japan"); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-9.js b/courses/backend/advanced-javascript/week1/in-class/exercise-9.js new file mode 100644 index 000000000..e7d448179 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-9.js @@ -0,0 +1,3 @@ +import { teas } from "../data/teas.js"; + +const highCaffeineTeas = teas.filter(tea => tea.caffeineLevel === "high"); \ No newline at end of file From 711e5ab7ed5ced0002effc8a88f70af48030ea30 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 15:29:19 +0100 Subject: [PATCH 098/113] added homework 1 --- .../advanced-javascript/week1/homework/homework1.js | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/homework/homework1.js diff --git a/courses/backend/advanced-javascript/week1/homework/homework1.js b/courses/backend/advanced-javascript/week1/homework/homework1.js new file mode 100644 index 000000000..7430023a2 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/homework/homework1.js @@ -0,0 +1,7 @@ +import { teas } from "../data/teas.js"; + +const result = teas + .filter(tea => tea.caffeineLevel !== 'none') + .map(tea => tea.name.toUpperCase() ) + +console.log(result); \ No newline at end of file From cecb0a3b83601dc3d5f8dd0fb2dc37774f3b50b0 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 15:29:34 +0100 Subject: [PATCH 099/113] added homework 2 --- .../week1/homework/homework2.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/homework/homework2.js diff --git a/courses/backend/advanced-javascript/week1/homework/homework2.js b/courses/backend/advanced-javascript/week1/homework/homework2.js new file mode 100644 index 000000000..19beda0e9 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/homework/homework2.js @@ -0,0 +1,18 @@ +import { teas } from "../data/teas.js"; + +function inventoryReport(teas) { + const totalTeas = teas.length; + const inStock = teas.filter(tea => tea.inStock).length; + const outOfStock = totalTeas - inStock; + const totalInventoryValue = teas.map(tea => tea.pricePerGram * tea.stockCount).reduce((x, y) => x + y); + const averagePrice = Number((totalInventoryValue / totalTeas).toFixed(2)); + return { + totalTeas, + inStock, + outOfStock, + totalInventoryValue, + averagePrice + } + }; + +console.log(inventoryReport(teas)); \ No newline at end of file From bbfe1afb6918aeb6108d43760216127080245d14 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 15:41:22 +0100 Subject: [PATCH 100/113] added homework 3 --- .../advanced-javascript/week1/homework/homework3.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/homework/homework3.js diff --git a/courses/backend/advanced-javascript/week1/homework/homework3.js b/courses/backend/advanced-javascript/week1/homework/homework3.js new file mode 100644 index 000000000..d54463286 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/homework/homework3.js @@ -0,0 +1,12 @@ +import { teas } from "../data/teas.js"; + +function lowStockAlert(teas) { + return teas.map(tea => { + return { + name: tea.name, + stock: tea.stockCount + } + }).sort((a, b) => a.stock - b.stock); +} + +console.log(lowStockAlert(teas)); \ No newline at end of file From ed7496fa39c376075a8c46de4378a0a8e4f3f75f Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 15:43:32 +0100 Subject: [PATCH 101/113] corrected homework 3 to properly filter out all teas with stockCount under 50 --- courses/backend/advanced-javascript/week1/homework/homework3.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/courses/backend/advanced-javascript/week1/homework/homework3.js b/courses/backend/advanced-javascript/week1/homework/homework3.js index d54463286..9eebb02cd 100644 --- a/courses/backend/advanced-javascript/week1/homework/homework3.js +++ b/courses/backend/advanced-javascript/week1/homework/homework3.js @@ -1,7 +1,7 @@ import { teas } from "../data/teas.js"; function lowStockAlert(teas) { - return teas.map(tea => { + return teas.filter(tea => tea.stockCount < 50).map(tea => { return { name: tea.name, stock: tea.stockCount From a8ea00de69c4d17de35c93ac9e8f0296eda58f84 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 15:55:25 +0100 Subject: [PATCH 102/113] added homework 4 --- .../week1/homework/homework4.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/homework/homework4.js diff --git a/courses/backend/advanced-javascript/week1/homework/homework4.js b/courses/backend/advanced-javascript/week1/homework/homework4.js new file mode 100644 index 000000000..5806734b6 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/homework/homework4.js @@ -0,0 +1,16 @@ +import { teas } from "../data/teas.js"; + +function teasByOrigin(teas) { + let origins = {}; + teas.forEach(tea => { + const origin = tea.origin; + if (!origins[origin]) { + origins[origin] = 1; + } else { + origins[origin]++; + } + }); + return origins; +} + +console.log(teasByOrigin(teas)); \ No newline at end of file From b9204ae4ef0eac3b3dd13184f6158347e86bf84e Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 15:57:35 +0100 Subject: [PATCH 103/113] changed homework four to correctly list all teas in each category rather than total count --- .../backend/advanced-javascript/week1/homework/homework4.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/courses/backend/advanced-javascript/week1/homework/homework4.js b/courses/backend/advanced-javascript/week1/homework/homework4.js index 5806734b6..ecdb0515e 100644 --- a/courses/backend/advanced-javascript/week1/homework/homework4.js +++ b/courses/backend/advanced-javascript/week1/homework/homework4.js @@ -5,9 +5,9 @@ function teasByOrigin(teas) { teas.forEach(tea => { const origin = tea.origin; if (!origins[origin]) { - origins[origin] = 1; + origins[origin] = [tea.name]; } else { - origins[origin]++; + origins[origin].push(tea.name); } }); return origins; From 74ee8f9e2ee218d65b4d6d0cd46fbcb03558a0a7 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 17:20:12 +0100 Subject: [PATCH 104/113] added homework 5 --- .../week1/homework/homework5.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/homework/homework5.js diff --git a/courses/backend/advanced-javascript/week1/homework/homework5.js b/courses/backend/advanced-javascript/week1/homework/homework5.js new file mode 100644 index 000000000..1e3f51817 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/homework/homework5.js @@ -0,0 +1,18 @@ +import { teas } from "../data/teas.js"; + +function searchTeas(teas, query) { + const queryLower = query.toLowerCase(); + // Return teas where the name contains the query (case-insensitive) + const filtered = teas.filter(tea => tea.name.toLowerCase().includes(queryLower)); + // Return just the names, sorted alphabetically + return filtered.map(tea => tea.name); +} + +console.log(searchTeas(teas, "earl")); +// Returns: [ 'Earl Grey', 'Jasmine Pearl' ] + +console.log(searchTeas(teas, "dragon")); +// Returns: ["Dragon Well"] + +console.log(searchTeas(teas, "ch")); +// Returns: ["Sencha", "Chamomile", "Matcha", "Lapsang Souchong", "Genmaicha"] From fc6cab65e71b93d26fd11d998c0cbff56d811a6e Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 17:31:29 +0100 Subject: [PATCH 105/113] added homework 6 --- .../backend/advanced-javascript/week1/homework/homework6.js | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/homework/homework6.js diff --git a/courses/backend/advanced-javascript/week1/homework/homework6.js b/courses/backend/advanced-javascript/week1/homework/homework6.js new file mode 100644 index 000000000..fe05a62c8 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/homework/homework6.js @@ -0,0 +1,5 @@ +import { teas } from "../data/teas.js"; + +const totalValue = teas.reduce((sum, tea) => sum + tea.pricePerGram * tea.stockCount, 0); + +console.log("Total inventory value:", totalValue); \ No newline at end of file From 7f9169a01bbc29156972dc01c0e48faa9a774677 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 17:45:35 +0100 Subject: [PATCH 106/113] added homework 7 --- .../advanced-javascript/week1/homework/homework7.js | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 courses/backend/advanced-javascript/week1/homework/homework7.js diff --git a/courses/backend/advanced-javascript/week1/homework/homework7.js b/courses/backend/advanced-javascript/week1/homework/homework7.js new file mode 100644 index 000000000..118e53168 --- /dev/null +++ b/courses/backend/advanced-javascript/week1/homework/homework7.js @@ -0,0 +1,9 @@ +import { teas } from "../data/teas.js"; + +const countByType = teas.reduce((counts, tea) => { + counts[tea.type] ? counts[tea.type]++ : counts[tea.type] = 1; + return counts; +}, {}); + +console.log(countByType); +// Expected: { green: 6, black: 6, herbal: 4, oolong: 2, white: 2 } \ No newline at end of file From 9176cec9185a40c0c4561838d6421784c52825b4 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 17:55:03 +0100 Subject: [PATCH 107/113] restored missing console log statements and cleaned up files --- .../week1/in-class/exercise-10.js | 4 +++- .../week1/in-class/exercise-11.js | 4 +++- .../week1/in-class/exercise-12.js | 4 +++- .../week1/in-class/exercise-13.js | 4 +++- .../week1/in-class/exercise-17.js | 24 +++++++++---------- .../week1/in-class/exercise-4.js | 4 +++- .../week1/in-class/exercise-7.js | 4 +++- .../week1/in-class/exercise-8.js | 4 +++- .../week1/in-class/exercise-9.js | 4 +++- 9 files changed, 35 insertions(+), 21 deletions(-) diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-10.js b/courses/backend/advanced-javascript/week1/in-class/exercise-10.js index ddff41f12..938f6e254 100644 --- a/courses/backend/advanced-javascript/week1/in-class/exercise-10.js +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-10.js @@ -1,3 +1,5 @@ import { teas } from "../data/teas.js"; -const organicTeasInStock = teas.filter(tea => tea.inStock).filter(tea => tea.organic); \ No newline at end of file +const organicTeasInStock = teas.filter(tea => tea.inStock).filter(tea => tea.organic); + +console.log(organicTeasInStock); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-11.js b/courses/backend/advanced-javascript/week1/in-class/exercise-11.js index d4a7f4110..234bbd786 100644 --- a/courses/backend/advanced-javascript/week1/in-class/exercise-11.js +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-11.js @@ -1,3 +1,5 @@ import { teas } from "../data/teas.js"; -const greenTeaNames = teas.filter(tea => tea.type === "green").map(tea => tea.name); \ No newline at end of file +const greenTeaNames = teas.filter(tea => tea.type === "green").map(tea => tea.name); + +console.log(greenTeaNames); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-12.js b/courses/backend/advanced-javascript/week1/in-class/exercise-12.js index 1fc7a5b5d..bbda13d30 100644 --- a/courses/backend/advanced-javascript/week1/in-class/exercise-12.js +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-12.js @@ -1,3 +1,5 @@ import { teas } from "../data/teas.js"; -const organicTeaStrings = teas.filter(tea => tea.organic).map(tea => `${tea.name} - ${tea.pricePerGram * 100} DKK/100g`); \ No newline at end of file +const organicTeaStrings = teas.filter(tea => tea.organic).map(tea => `${tea.name} - ${tea.pricePerGram * 100} DKK/100g`); + +console.log(organicTeaStrings); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-13.js b/courses/backend/advanced-javascript/week1/in-class/exercise-13.js index 2952565de..9038af676 100644 --- a/courses/backend/advanced-javascript/week1/in-class/exercise-13.js +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-13.js @@ -1,3 +1,5 @@ import { teas } from "../data/teas.js"; -const japaneseTeasByPrice = teas.filter(tea => tea.origin === "Japan").sort((a, b) => a.pricePerGram - b.pricePerGram); \ No newline at end of file +const japaneseTeasByPrice = teas.filter(tea => tea.origin === "Japan").sort((a, b) => a.pricePerGram - b.pricePerGram); + +console.log(japaneseTeasByPrice); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-17.js b/courses/backend/advanced-javascript/week1/in-class/exercise-17.js index ce374c44c..adb2ef4c4 100644 --- a/courses/backend/advanced-javascript/week1/in-class/exercise-17.js +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-17.js @@ -1,15 +1,3 @@ -// filterTeas(teas, { organic: true }); -// // Returns all organic teas - -// filterTeas(teas, { origin: "Japan" }); -// // Returns all Japanese teas - -// filterTeas(teas, { organic: true, origin: "Japan" }); -// // Returns organic Japanese teas - -// filterTeas(teas, { type: "green", inStock: true }); -// // Returns green teas that are in stock - import { teas } from "../data/teas.js"; function filterTeas (teas, obj) { @@ -22,4 +10,14 @@ function filterTeas (teas, obj) { return teas; } -console.log(filterTeas(teas, { type: "green", inStock: true })); \ No newline at end of file +console.log('Organic teas: ', filterTeas(teas, { organic: true })) +// Returns all organic teas + +console.log('Japanese teas: ', filterTeas(teas, { origin: "Japan" })) +// Returns all Japanese teas + +console.log('Organic Japanese teas: ', filterTeas(teas, { organic: true, origin: "Japan" })) +// Returns organic Japanese teas + +console.log('Green teas in stock: ', filterTeas(teas, { type: "green", inStock: true })) +// Returns green teas that are in stock); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-4.js b/courses/backend/advanced-javascript/week1/in-class/exercise-4.js index 6e3a12f35..664dc0363 100644 --- a/courses/backend/advanced-javascript/week1/in-class/exercise-4.js +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-4.js @@ -1,3 +1,5 @@ import { teas } from "../data/teas.js"; -const teaNames = teas.map(tea => tea.name); \ No newline at end of file +const teaNames = teas.map(tea => tea.name); + +console.log(teaNames); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-7.js b/courses/backend/advanced-javascript/week1/in-class/exercise-7.js index 148fdc166..163d66fc7 100644 --- a/courses/backend/advanced-javascript/week1/in-class/exercise-7.js +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-7.js @@ -1,3 +1,5 @@ import { teas } from "../data/teas.js"; -const organicTeas = teas.filter(tea => tea.organic); \ No newline at end of file +const organicTeas = teas.filter(tea => tea.organic); + +console.log(organicTeas); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-8.js b/courses/backend/advanced-javascript/week1/in-class/exercise-8.js index 9177854a5..e290ebec9 100644 --- a/courses/backend/advanced-javascript/week1/in-class/exercise-8.js +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-8.js @@ -1,3 +1,5 @@ import { teas } from "../data/teas.js"; -const japaneseTeas = teas.filter(tea => tea.origin === "Japan"); \ No newline at end of file +const japaneseTeas = teas.filter(tea => tea.origin === "Japan"); + +console.log(japaneseTeas); \ No newline at end of file diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-9.js b/courses/backend/advanced-javascript/week1/in-class/exercise-9.js index e7d448179..9937e9790 100644 --- a/courses/backend/advanced-javascript/week1/in-class/exercise-9.js +++ b/courses/backend/advanced-javascript/week1/in-class/exercise-9.js @@ -1,3 +1,5 @@ import { teas } from "../data/teas.js"; -const highCaffeineTeas = teas.filter(tea => tea.caffeineLevel === "high"); \ No newline at end of file +const highCaffeineTeas = teas.filter(tea => tea.caffeineLevel === "high"); + +console.log(highCaffeineTeas); \ No newline at end of file From b4b92f6b8f8b0f12cc56e739428d77a4c71f42f2 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Sun, 8 Mar 2026 17:58:44 +0100 Subject: [PATCH 108/113] changed filenames to conform with submission requirements --- .../week1/homework/{homework1.js => exercise1.js} | 0 .../week1/homework/{homework2.js => exercise2.js} | 0 .../week1/homework/{homework3.js => exercise3.js} | 0 .../week1/homework/{homework4.js => exercise4.js} | 0 .../week1/homework/{homework5.js => exercise5.js} | 0 .../week1/homework/{homework6.js => exercise6.js} | 0 .../week1/homework/{homework7.js => exercise7.js} | 0 .../week1/in-class/{exercise-1.js => exercise1.js} | 0 .../week1/in-class/{exercise-10.js => exercise10.js} | 0 .../week1/in-class/{exercise-11.js => exercise11.js} | 0 .../week1/in-class/{exercise-12.js => exercise12.js} | 0 .../week1/in-class/{exercise-13.js => exercise13.js} | 0 .../week1/in-class/{exercise-17.js => exercise17.js} | 0 .../week1/in-class/{exercise-2.js => exercise2.js} | 0 .../week1/in-class/{exercise-3.js => exercise3.js} | 0 .../week1/in-class/{exercise-4.js => exercise4.js} | 0 .../week1/in-class/{exercise-5.js => exercise5.js} | 0 .../week1/in-class/{exercise-6.js => exercise6.js} | 0 .../week1/in-class/{exercise-7.js => exercise7.js} | 0 .../week1/in-class/{exercise-8.js => exercise8.js} | 0 .../week1/in-class/{exercise-9.js => exercise9.js} | 0 21 files changed, 0 insertions(+), 0 deletions(-) rename courses/backend/advanced-javascript/week1/homework/{homework1.js => exercise1.js} (100%) rename courses/backend/advanced-javascript/week1/homework/{homework2.js => exercise2.js} (100%) rename courses/backend/advanced-javascript/week1/homework/{homework3.js => exercise3.js} (100%) rename courses/backend/advanced-javascript/week1/homework/{homework4.js => exercise4.js} (100%) rename courses/backend/advanced-javascript/week1/homework/{homework5.js => exercise5.js} (100%) rename courses/backend/advanced-javascript/week1/homework/{homework6.js => exercise6.js} (100%) rename courses/backend/advanced-javascript/week1/homework/{homework7.js => exercise7.js} (100%) rename courses/backend/advanced-javascript/week1/in-class/{exercise-1.js => exercise1.js} (100%) rename courses/backend/advanced-javascript/week1/in-class/{exercise-10.js => exercise10.js} (100%) rename courses/backend/advanced-javascript/week1/in-class/{exercise-11.js => exercise11.js} (100%) rename courses/backend/advanced-javascript/week1/in-class/{exercise-12.js => exercise12.js} (100%) rename courses/backend/advanced-javascript/week1/in-class/{exercise-13.js => exercise13.js} (100%) rename courses/backend/advanced-javascript/week1/in-class/{exercise-17.js => exercise17.js} (100%) rename courses/backend/advanced-javascript/week1/in-class/{exercise-2.js => exercise2.js} (100%) rename courses/backend/advanced-javascript/week1/in-class/{exercise-3.js => exercise3.js} (100%) rename courses/backend/advanced-javascript/week1/in-class/{exercise-4.js => exercise4.js} (100%) rename courses/backend/advanced-javascript/week1/in-class/{exercise-5.js => exercise5.js} (100%) rename courses/backend/advanced-javascript/week1/in-class/{exercise-6.js => exercise6.js} (100%) rename courses/backend/advanced-javascript/week1/in-class/{exercise-7.js => exercise7.js} (100%) rename courses/backend/advanced-javascript/week1/in-class/{exercise-8.js => exercise8.js} (100%) rename courses/backend/advanced-javascript/week1/in-class/{exercise-9.js => exercise9.js} (100%) diff --git a/courses/backend/advanced-javascript/week1/homework/homework1.js b/courses/backend/advanced-javascript/week1/homework/exercise1.js similarity index 100% rename from courses/backend/advanced-javascript/week1/homework/homework1.js rename to courses/backend/advanced-javascript/week1/homework/exercise1.js diff --git a/courses/backend/advanced-javascript/week1/homework/homework2.js b/courses/backend/advanced-javascript/week1/homework/exercise2.js similarity index 100% rename from courses/backend/advanced-javascript/week1/homework/homework2.js rename to courses/backend/advanced-javascript/week1/homework/exercise2.js diff --git a/courses/backend/advanced-javascript/week1/homework/homework3.js b/courses/backend/advanced-javascript/week1/homework/exercise3.js similarity index 100% rename from courses/backend/advanced-javascript/week1/homework/homework3.js rename to courses/backend/advanced-javascript/week1/homework/exercise3.js diff --git a/courses/backend/advanced-javascript/week1/homework/homework4.js b/courses/backend/advanced-javascript/week1/homework/exercise4.js similarity index 100% rename from courses/backend/advanced-javascript/week1/homework/homework4.js rename to courses/backend/advanced-javascript/week1/homework/exercise4.js diff --git a/courses/backend/advanced-javascript/week1/homework/homework5.js b/courses/backend/advanced-javascript/week1/homework/exercise5.js similarity index 100% rename from courses/backend/advanced-javascript/week1/homework/homework5.js rename to courses/backend/advanced-javascript/week1/homework/exercise5.js diff --git a/courses/backend/advanced-javascript/week1/homework/homework6.js b/courses/backend/advanced-javascript/week1/homework/exercise6.js similarity index 100% rename from courses/backend/advanced-javascript/week1/homework/homework6.js rename to courses/backend/advanced-javascript/week1/homework/exercise6.js diff --git a/courses/backend/advanced-javascript/week1/homework/homework7.js b/courses/backend/advanced-javascript/week1/homework/exercise7.js similarity index 100% rename from courses/backend/advanced-javascript/week1/homework/homework7.js rename to courses/backend/advanced-javascript/week1/homework/exercise7.js diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-1.js b/courses/backend/advanced-javascript/week1/in-class/exercise1.js similarity index 100% rename from courses/backend/advanced-javascript/week1/in-class/exercise-1.js rename to courses/backend/advanced-javascript/week1/in-class/exercise1.js diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-10.js b/courses/backend/advanced-javascript/week1/in-class/exercise10.js similarity index 100% rename from courses/backend/advanced-javascript/week1/in-class/exercise-10.js rename to courses/backend/advanced-javascript/week1/in-class/exercise10.js diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-11.js b/courses/backend/advanced-javascript/week1/in-class/exercise11.js similarity index 100% rename from courses/backend/advanced-javascript/week1/in-class/exercise-11.js rename to courses/backend/advanced-javascript/week1/in-class/exercise11.js diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-12.js b/courses/backend/advanced-javascript/week1/in-class/exercise12.js similarity index 100% rename from courses/backend/advanced-javascript/week1/in-class/exercise-12.js rename to courses/backend/advanced-javascript/week1/in-class/exercise12.js diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-13.js b/courses/backend/advanced-javascript/week1/in-class/exercise13.js similarity index 100% rename from courses/backend/advanced-javascript/week1/in-class/exercise-13.js rename to courses/backend/advanced-javascript/week1/in-class/exercise13.js diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-17.js b/courses/backend/advanced-javascript/week1/in-class/exercise17.js similarity index 100% rename from courses/backend/advanced-javascript/week1/in-class/exercise-17.js rename to courses/backend/advanced-javascript/week1/in-class/exercise17.js diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-2.js b/courses/backend/advanced-javascript/week1/in-class/exercise2.js similarity index 100% rename from courses/backend/advanced-javascript/week1/in-class/exercise-2.js rename to courses/backend/advanced-javascript/week1/in-class/exercise2.js diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-3.js b/courses/backend/advanced-javascript/week1/in-class/exercise3.js similarity index 100% rename from courses/backend/advanced-javascript/week1/in-class/exercise-3.js rename to courses/backend/advanced-javascript/week1/in-class/exercise3.js diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-4.js b/courses/backend/advanced-javascript/week1/in-class/exercise4.js similarity index 100% rename from courses/backend/advanced-javascript/week1/in-class/exercise-4.js rename to courses/backend/advanced-javascript/week1/in-class/exercise4.js diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-5.js b/courses/backend/advanced-javascript/week1/in-class/exercise5.js similarity index 100% rename from courses/backend/advanced-javascript/week1/in-class/exercise-5.js rename to courses/backend/advanced-javascript/week1/in-class/exercise5.js diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-6.js b/courses/backend/advanced-javascript/week1/in-class/exercise6.js similarity index 100% rename from courses/backend/advanced-javascript/week1/in-class/exercise-6.js rename to courses/backend/advanced-javascript/week1/in-class/exercise6.js diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-7.js b/courses/backend/advanced-javascript/week1/in-class/exercise7.js similarity index 100% rename from courses/backend/advanced-javascript/week1/in-class/exercise-7.js rename to courses/backend/advanced-javascript/week1/in-class/exercise7.js diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-8.js b/courses/backend/advanced-javascript/week1/in-class/exercise8.js similarity index 100% rename from courses/backend/advanced-javascript/week1/in-class/exercise-8.js rename to courses/backend/advanced-javascript/week1/in-class/exercise8.js diff --git a/courses/backend/advanced-javascript/week1/in-class/exercise-9.js b/courses/backend/advanced-javascript/week1/in-class/exercise9.js similarity index 100% rename from courses/backend/advanced-javascript/week1/in-class/exercise-9.js rename to courses/backend/advanced-javascript/week1/in-class/exercise9.js From c5c70dd2297620e79e0d24c1291247535433576a Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Fri, 13 Mar 2026 14:05:17 +0100 Subject: [PATCH 109/113] improved styling in line with feedback --- courses/backend/advanced-javascript/week1/homework/exercise1.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/courses/backend/advanced-javascript/week1/homework/exercise1.js b/courses/backend/advanced-javascript/week1/homework/exercise1.js index 7430023a2..7026fff4e 100644 --- a/courses/backend/advanced-javascript/week1/homework/exercise1.js +++ b/courses/backend/advanced-javascript/week1/homework/exercise1.js @@ -2,6 +2,6 @@ import { teas } from "../data/teas.js"; const result = teas .filter(tea => tea.caffeineLevel !== 'none') - .map(tea => tea.name.toUpperCase() ) + .map(tea => tea.name.toUpperCase()); console.log(result); \ No newline at end of file From 90dabb5b6c24118e30c655ec36a2e84d87f68a26 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Fri, 13 Mar 2026 14:12:54 +0100 Subject: [PATCH 110/113] fixed calculation of average price to properly return averagePricePerGram --- .../advanced-javascript/week1/homework/exercise2.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/courses/backend/advanced-javascript/week1/homework/exercise2.js b/courses/backend/advanced-javascript/week1/homework/exercise2.js index 19beda0e9..9af58797b 100644 --- a/courses/backend/advanced-javascript/week1/homework/exercise2.js +++ b/courses/backend/advanced-javascript/week1/homework/exercise2.js @@ -4,14 +4,15 @@ function inventoryReport(teas) { const totalTeas = teas.length; const inStock = teas.filter(tea => tea.inStock).length; const outOfStock = totalTeas - inStock; - const totalInventoryValue = teas.map(tea => tea.pricePerGram * tea.stockCount).reduce((x, y) => x + y); - const averagePrice = Number((totalInventoryValue / totalTeas).toFixed(2)); + const totalInventoryValue = teas.map(tea => tea.pricePerGram * tea.stockCount).reduce((x, y) => x + y, 0); + const totalPricePerGram = teas.map(tea => tea.pricePerGram).reduce((x, y) => x + y, 0); + const averagePricePerGram = Number((totalPricePerGram / totalTeas).toFixed(2)); return { totalTeas, inStock, outOfStock, totalInventoryValue, - averagePrice + averagePricePerGram } }; From 4ca9ee92e1686dee9cf812e16a353f2fdd761ba1 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Fri, 13 Mar 2026 14:17:16 +0100 Subject: [PATCH 111/113] refactored searchTeas to alphabetically sort the list of teas before returning --- .../backend/advanced-javascript/week1/homework/exercise5.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/courses/backend/advanced-javascript/week1/homework/exercise5.js b/courses/backend/advanced-javascript/week1/homework/exercise5.js index 1e3f51817..78fa70bc8 100644 --- a/courses/backend/advanced-javascript/week1/homework/exercise5.js +++ b/courses/backend/advanced-javascript/week1/homework/exercise5.js @@ -5,7 +5,8 @@ function searchTeas(teas, query) { // Return teas where the name contains the query (case-insensitive) const filtered = teas.filter(tea => tea.name.toLowerCase().includes(queryLower)); // Return just the names, sorted alphabetically - return filtered.map(tea => tea.name); + const names = filtered.map(tea => tea.name).sort(); + return names; } console.log(searchTeas(teas, "earl")); From c022cc738f5dfa403b8336927b0a6f71c7947cd9 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 13 Apr 2026 22:40:57 +0200 Subject: [PATCH 112/113] add week 1 assignment: task management database --- .../week4/homework/exercise5.js | 18 ++ courses/backend/databases/database/tasks.sql | 292 ++++++++++++++++++ 2 files changed, 310 insertions(+) create mode 100644 courses/backend/advanced-javascript/week4/homework/exercise5.js create mode 100644 courses/backend/databases/database/tasks.sql diff --git a/courses/backend/advanced-javascript/week4/homework/exercise5.js b/courses/backend/advanced-javascript/week4/homework/exercise5.js new file mode 100644 index 000000000..b8d4fedfb --- /dev/null +++ b/courses/backend/advanced-javascript/week4/homework/exercise5.js @@ -0,0 +1,18 @@ +import { teas } from "../../week1/data/teas.js"; +import { TeaShop } from "../classes.js"; + +const shop = new TeaShop(teas); + +const alex = shop.registerCustomer("Alex", "alex@example.com"); +const maria = shop.registerCustomer("Maria", "maria@example.com"); + +const order1 = shop.createOrder(alex, [ + { teaName: "Sencha", grams: 100 }, + { teaName: "Matcha", grams: 50 }, +]); +console.log(order1.getSummary()); + +const order2 = shop.createOrder(maria, [{ teaName: "Earl Grey", grams: 200 }]); +console.log(order2.getSummary()); + +console.log(shop.getReport()); \ No newline at end of file diff --git a/courses/backend/databases/database/tasks.sql b/courses/backend/databases/database/tasks.sql new file mode 100644 index 000000000..54af838b9 --- /dev/null +++ b/courses/backend/databases/database/tasks.sql @@ -0,0 +1,292 @@ +CREATE TABLE user ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL, + email TEXT UNIQUE, + phone TEXT UNIQUE +); + +CREATE TABLE task ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + title TEXT NOT NULL, + description TEXT, + due_date DATETIME, + created DATETIME NOT NULL, + updated DATETIME NOT NULL, + status_id INTEGER NOT NULL DEFAULT 1, + FOREIGN KEY (status_id) REFERENCES status(id) +); + +CREATE TABLE status ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL UNIQUE +); + +CREATE TABLE user_task ( + user_id INTEGER NOT NULL, + task_id INTEGER NOT NULL, + PRIMARY KEY (user_id, task_id), + FOREIGN KEY (user_id) REFERENCES user(id) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (task_id) REFERENCES task(id) ON DELETE CASCADE ON UPDATE CASCADE +); + +INSERT INTO status (name) VALUES ('not started'); +INSERT INTO status (name) VALUES ('in progress'); +INSERT INTO status (name) VALUES ('finished'); + +INSERT INTO user (name, email, phone) VALUES + ('John Doe', '', '+4512345678'), + ('Jane Smith', 'jane@gmail.com', '+4512345679'); + +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES + ('Study SQL Queries', 'Practice writing SQL queries for data retrieval', datetime('now'), datetime('now'), '2025-08-02', 3), + ('Learn Database Design', 'Study ER modeling and normalization', datetime('now'), datetime('now'), '2025-08-10', 1), + ('Write Unit Tests', 'Add test coverage for user authentication', datetime('now'), datetime('now'), '2025-08-05', 1), + ('Deploy Application', 'Set up production environment', datetime('now'), datetime('now'), '2025-08-20', 1); + + + +-- Users +INSERT INTO user (name, email, phone) VALUES ('Aarika Ellingworth', 'aellingworth0@harvard.edu', '483-396-8795'); +INSERT INTO user (name, email, phone) VALUES ('Pren Goldsworthy', 'pgoldsworthy1@spotify.com', '635-572-8467'); +INSERT INTO user (name, email, phone) VALUES ('Pablo Kisbee', 'pkisbee2@lulu.com', '790-962-8683'); +INSERT INTO user (name, email, phone) VALUES ('Rodie Duncan', 'rduncan3@quantcast.com', '646-743-6191'); +INSERT INTO user (name, email, phone) VALUES ('Aubry Polak', 'apolak4@indiatimes.com', '302-678-7931'); +INSERT INTO user (name, email, phone) VALUES ('Maryrose Meadows', 'mmeadows5@comcast.net', '251-524-6594'); +INSERT INTO user (name, email, phone) VALUES ('Pavel Brushneen', 'pbrushneen6@techcrunch.com', '316-170-3640'); +INSERT INTO user (name, email, phone) VALUES ('Hedy Gerault', 'hgerault7@nymag.com', '176-177-5579'); +INSERT INTO user (name, email, phone) VALUES ('王秀英', 'wang.xiuying@weebly.com', '891-952-6749'); +INSERT INTO user (name, email, phone) VALUES ('إلياس', 'elias@github.com', '202-517-6983'); +INSERT INTO user (name, email, phone) VALUES ('Donald Duck', 'donald@duck.com', NULL); + + +-- Tasks +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Wash clothes', 'Title says it all.', '2017-10-25 06:54:16', '2017-10-15 13:05:09', null, 2); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Become a billionaire', 'This should not take long, just invent a time machine, travel back to 2010 and buy bitcoin', '2017-09-26 03:06:46', '2017-10-08 06:14:31', '2017-12-22 20:58:03', 3); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Plan meeting with London office', 'We will probably use skype', '2017-10-04 18:07:37', '2017-10-14 16:01:31', '2017-12-05 19:42:15', 2); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Order groceries online', 'The fridge is almost empty, we need eggs and milk', '2017-09-20 19:34:43', '2017-10-15 23:35:45', '2017-12-24 16:00:46', 1); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Empty the mailbox', NULL, '2017-09-27 15:17:08', '2017-10-08 17:31:16', null, 2); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Fix the flat tire on the bike', 'Tools are in the garage', '2017-09-13 23:16:30', '2017-10-06 04:03:52', '2017-12-07 11:51:11', 2); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Wash the car', NULL, '2017-10-06 19:39:16', '2017-10-03 04:49:05', '2017-12-04 17:43:16', 2); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Walk the dog', NULL, '2017-09-03 02:47:17', '2017-10-12 18:40:08', null, 3); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Write a book', 'Maybe something about dragons?', '2017-10-11 06:14:01', '2017-10-17 12:19:08', '2017-12-21 20:18:05', 2); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Do HackYourFuture assignment', NULL, '2017-10-04 13:55:16', '2017-10-10 00:18:05', '2017-12-19 17:01:10', 1); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Iron shirts', NULL, '2017-09-23 03:59:58', '2017-10-19 08:30:48', '2017-12-08 11:00:35', 3); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Water the potted plants', 'Maybe they need fertilizer as well', '2017-09-29 23:38:42', '2017-10-08 04:24:53', null, 2); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Buy wine for the birthday party', 'Both red and white wine', '2017-10-10 14:57:22', '2017-10-14 14:03:30', '2017-12-10 23:43:56', 2); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Buy gift for Paul', 'He could use a shirt or a tie and some socks', '2017-09-09 05:22:08', '2017-10-17 15:58:05', '2017-12-04 20:45:18', 3); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Change lightbulb in hallway', 'Should be an LED bulb', '2017-10-01 19:07:35', '2017-10-03 10:02:27', '2017-12-08 17:09:03', 3); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Wash windows', NULL, '2017-10-02 22:15:17', '2017-10-07 22:31:35', '2017-12-06 03:36:09', 2); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Setup salary databases for accounting', 'Use MySQL', '2017-10-25 05:35:33', '2017-10-10 23:22:33', '2017-12-05 00:19:08', 1); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Learn how databases work', NULL, '2017-09-06 03:16:47', '2017-10-10 16:56:58', '2017-12-18 05:08:05', 3); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Make the databases perform better', 'It should be possible to optimize the indexes', '2017-10-03 09:27:20', '2017-10-01 16:27:46', '2017-12-01 13:28:35', 2); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Buy beer for the company party', '2 or 3 cases should be enough', '2017-10-08 01:39:02', '2017-10-13 23:07:41', null, 3); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Knit sweater', NULL, '2017-09-22 17:14:55', '2017-10-08 09:01:35', '2017-12-15 20:33:57', 2); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Charge electric bicycle', 'It sucks to ride it without a battery!', '2017-10-10 12:25:07', '2017-10-07 21:45:01', '2017-12-10 19:02:17', 1); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Buy new phone', 'The battery in the current one only lasts 5 hours 😞', '2017-09-17 00:25:34', '2017-10-09 11:48:12', null, 3); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Ride bike around Sjælland', 'Remember rainclothes and tire repair kit!', '2017-10-20 19:21:13', '2017-10-07 01:38:06', '2017-12-19 15:08:18', 2); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Look at apartments in Ørestad', '2 or 3 rooms', '2017-10-30 09:47:00', '2017-10-19 06:11:26', null, 1); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Empty Mr Fluffy''s litterbox', NULL, '2017-09-28 03:09:06', '2017-10-13 10:38:34', '2017-12-20 23:37:18', 2); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Buy new dining room table and chairs', 'Ikea has some on sale', '2017-09-21 12:02:34', '2017-10-02 02:05:11', '2017-12-06 00:14:30', 1); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Renew buscard', '3 zones', '2017-10-07 22:47:51', '2017-10-09 15:50:03', '2017-12-01 14:25:40', 2); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Sign up for linkedin', 'Make the CV awesome! 😄', '2017-09-04 00:57:47', '2017-10-18 18:07:48', '2017-12-07 23:04:38', 3); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Remove facebook from phone', 'To avoid interruptions when working', '2017-10-26 17:15:07', '2017-10-13 03:36:47', '2017-12-19 11:10:02', 3); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Backup databases to external disk', 'Remember to store the disk in another physical location', '2017-09-09 17:32:33', '2017-10-01 21:18:59', '2017-12-23 14:21:01', 1); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Put up the new lamp in the hallway', NULL, '2017-10-15 05:45:54', '2017-10-16 14:05:35', '2017-12-29 02:29:26', 3); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Hang up paintings in living room', NULL, '2017-09-10 05:36:11', '2017-10-09 17:40:42', null, 3); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Buy plane ticket to Auckland', 'Check prices online first!', '2017-09-05 09:07:22', '2017-10-15 09:36:06', '2017-12-07 11:10:05', 1); +INSERT INTO task (title, description, created, updated, due_date, status_id) VALUES ('Learn about NoSQL databases', 'MongoDB, CouchDB, etc.', '2017-10-20 01:41:53', '2017-10-04 07:19:56', '2017-12-23 10:13:42', 2); + +-- Users-tasks +INSERT INTO user_task (user_id, task_id) VALUES(1, 5); +INSERT INTO user_task (user_id, task_id) VALUES(1, 35); +INSERT INTO user_task (user_id, task_id) VALUES(1, 11); +INSERT INTO user_task (user_id, task_id) VALUES(2, 4); +INSERT INTO user_task (user_id, task_id) VALUES(2, 26); +INSERT INTO user_task (user_id, task_id) VALUES(2, 29); +INSERT INTO user_task (user_id, task_id) VALUES(3, 22); +INSERT INTO user_task (user_id, task_id) VALUES(3, 13); +INSERT INTO user_task (user_id, task_id) VALUES(3, 19); +INSERT INTO user_task (user_id, task_id) VALUES(4, 24); +INSERT INTO user_task (user_id, task_id) VALUES(4, 20); +INSERT INTO user_task (user_id, task_id) VALUES(5, 20); +INSERT INTO user_task (user_id, task_id) VALUES(5, 18); +INSERT INTO user_task (user_id, task_id) VALUES(5, 15); +INSERT INTO user_task (user_id, task_id) VALUES(6, 10); +INSERT INTO user_task (user_id, task_id) VALUES(6, 7); +INSERT INTO user_task (user_id, task_id) VALUES(6, 27); +INSERT INTO user_task (user_id, task_id) VALUES(7, 33); +INSERT INTO user_task (user_id, task_id) VALUES(7, 18); +INSERT INTO user_task (user_id, task_id) VALUES(7, 23); +INSERT INTO user_task (user_id, task_id) VALUES(8, 26); +INSERT INTO user_task (user_id, task_id) VALUES(8, 30); +INSERT INTO user_task (user_id, task_id) VALUES(8, 11); +INSERT INTO user_task (user_id, task_id) VALUES(9, 34); +INSERT INTO user_task (user_id, task_id) VALUES(9, 15); +INSERT INTO user_task (user_id, task_id) VALUES(9, 1); +INSERT INTO user_task (user_id, task_id) VALUES(10, 29); +INSERT INTO user_task (user_id, task_id) VALUES(10, 16); +INSERT INTO user_task (user_id, task_id) VALUES(10, 1); +INSERT INTO user_task (user_id, task_id) VALUES(11, 26); +INSERT INTO user_task (user_id, task_id) VALUES(11, 27); +INSERT INTO user_task (user_id, task_id) VALUES(11, 17); +INSERT INTO user_task (user_id, task_id) VALUES(11, 2); +INSERT INTO user_task (user_id, task_id) VALUES(1, 3); +INSERT INTO user_task (user_id, task_id) VALUES(2, 6); +INSERT INTO user_task (user_id, task_id) VALUES(3, 8); +INSERT INTO user_task (user_id, task_id) VALUES(4, 9); +INSERT INTO user_task (user_id, task_id) VALUES(5, 12); +INSERT INTO user_task (user_id, task_id) VALUES(6, 14); +INSERT INTO user_task (user_id, task_id) VALUES(7, 21); +INSERT INTO user_task (user_id, task_id) VALUES(8, 25); +INSERT INTO user_task (user_id, task_id) VALUES(9, 28); +INSERT INTO user_task (user_id, task_id) VALUES(10, 31); +INSERT INTO user_task (user_id, task_id) VALUES(11, 32); + +-- Assignment, Part 1: Basic CRUD Operations + +-- Part 1, Question 1: Insert a new user with your own name and email +INSERT INTO user (name, email, phone) + VALUES ('Jessica BK', 'jkavanagh00@gmail.com', NULL); + +-- Part 1, Question 2: Insert a new task assigned to yourself +INSERT INTO task (title, description, created, updated, due_date, status_id) + VALUES ('Learn SQL', 'Practice database queries', '2017-10-25 05:35:33', '2017-10-10 23:22:33', '2026-04-13 00:19:08', 2); +INSERT INTO user_task (user_id, task_id) + VALUES(12, 40); + +-- Part 1, Question 3: Update the title of the task +UPDATE task + SET title = 'Master SQL basics' + WHERE id = 40; + +-- Part 1, Question 4: Change the due date to two weeks from today +UPDATE task + SET due_date = '2026-04-27 00:19:08' + WHERE id = 40; + +-- Part 1, Question 5: Change task status to 'done' +UPDATE task + SET status_id = 3 + WHERE id = 40; + +-- Part 1, Question 6: Delete the task +DELETE FROM task + WHERE id = 40; +DELETE FROM user_task + WHERE task_id = 40; + +-- Assignment, Part 2: Working with Relationships + +-- Part 2, Question 1: List all users who don't have any tasks assigned +SELECT name + FROM user + WHERE id NOT IN (SELECT user_id FROM user_task); + +-- Part 2, Question 2: Find all tasks with a status of 'done' +SELECT * + FROM task + WHERE status_id = 3; + +-- Part 2, Question 3: Find all overdue tasks +SELECT * + FROM task + WHERE due_date < '2026-04-13'; + +-- Assignment, Part 3: Modifying the Database Schema + +-- Part 3, Question 1: Add the priority column to the task table and constrain possible values +ALTER TABLE task + ADD COLUMN priority TEXT NOT NULL DEFAULT 'medium' + CHECK (priority IN ('low', 'medium', 'high')); + +-- Part 3, Question 2: Create a mix of different priority tasks +UPDATE task + SET priority = 'low' + WHERE id > 20; +UPDATE task + SET priority = 'high' + WHERE id % 2 = 0; + +-- Part 3, Question 3: Create a new table called category +CREATE TABLE category ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT NOT NULL, + color TEXT NOT NULL +); + +-- Part 3, Question 4: Create a linking table task_category +CREATE TABLE task_category ( + task_id INTEGER NOT NULL, + category_id INTEGER NOT NULL, + PRIMARY KEY (task_id, category_id), + FOREIGN KEY (task_id) REFERENCES task(id) ON DELETE CASCADE ON UPDATE CASCADE, + FOREIGN KEY (category_id) REFERENCES category(id) ON DELETE CASCADE ON UPDATE CASCADE +); + +-- Part 3, Question 5: Insert categories +INSERT INTO category (name, color) VALUES ('work', 'blue'); +INSERT INTO category (name, color) VALUES ('personal', 'green'); +INSERT INTO category (name, color) VALUES ('study', 'red'); +INSERT INTO category (name, color) VALUES ('home', 'orange'); +INSERT INTO category (name, color) VALUES ('hobby', 'purple'); +INSERT INTO category (name, color) VALUES ('fun', 'yellow'); + +-- Part 3, Question 6: Assign categories to tasks +INSERT INTO task_category (task_id, category_id) VALUES (1, 3); +INSERT INTO task_category (task_id, category_id) VALUES (2, 3); +INSERT INTO task_category (task_id, category_id) VALUES (3, 1); +INSERT INTO task_category (task_id, category_id) VALUES (4, 1); +INSERT INTO task_category (task_id, category_id) VALUES (5, 4); +INSERT INTO task_category (task_id, category_id) VALUES (6, 2); +INSERT INTO task_category (task_id, category_id) VALUES (7, 1); + +-- Assignment, Part 4: Advanced Queries + +-- Part 4, Question 1: Find all tasks in a specific category (work, id 1) +SELECT * + FROM task_category tc + JOIN task t + WHERE tc.task_id = t.id + AND tc.category_id = 1; + +-- Part 4, Question 2: List tasks ordered by priority and due date +SELECT * +FROM task +ORDER BY + CASE priority + WHEN 'high' THEN 1 + WHEN 'medium' THEN 2 + WHEN 'low' THEN 3 + ELSE 4 + END, + due_date DESC; + +SELECT * FROM task_category tc; + +-- Part 4, Question 3: Find the category with the most tasks +SELECT + c.name AS category_name, + COUNT(tc.task_id) AS total_tasks +FROM task_category tc +JOIN category c ON c.id = tc.category_id +GROUP BY c.id, c.name +ORDER BY total_tasks DESC +LIMIT 1; + +-- Part 4, Question 4: Get all high priority tasks that are either 'in progress' or 'not started' +-- note: status labels are not consistent with those in exercise +SELECT * + FROM task t + WHERE priority = 'high' + AND (status_id = 1 OR status_id = 2); + +-- Part 4, Question 5: Find users who have tasks in more than one category +SELECT + u.name, + COUNT(DISTINCT tc.category_id) AS category_count +FROM user u +JOIN user_task ut ON u.id = ut.user_id +JOIN task_category tc ON tc.task_id = ut.task_id +GROUP BY u.id, u.name +HAVING COUNT(DISTINCT tc.category_id) > 1 +ORDER BY category_count DESC, u.name; \ No newline at end of file From 31a8ee259a3abe05d52f642c6a1183b6e61bf7d2 Mon Sep 17 00:00:00 2001 From: jkavanagh00 Date: Mon, 13 Apr 2026 22:57:41 +0200 Subject: [PATCH 113/113] remove exercise5.js accidentally committed to wrong branch --- .../week4/homework/exercise5.js | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 courses/backend/advanced-javascript/week4/homework/exercise5.js diff --git a/courses/backend/advanced-javascript/week4/homework/exercise5.js b/courses/backend/advanced-javascript/week4/homework/exercise5.js deleted file mode 100644 index b8d4fedfb..000000000 --- a/courses/backend/advanced-javascript/week4/homework/exercise5.js +++ /dev/null @@ -1,18 +0,0 @@ -import { teas } from "../../week1/data/teas.js"; -import { TeaShop } from "../classes.js"; - -const shop = new TeaShop(teas); - -const alex = shop.registerCustomer("Alex", "alex@example.com"); -const maria = shop.registerCustomer("Maria", "maria@example.com"); - -const order1 = shop.createOrder(alex, [ - { teaName: "Sencha", grams: 100 }, - { teaName: "Matcha", grams: 50 }, -]); -console.log(order1.getSummary()); - -const order2 = shop.createOrder(maria, [{ teaName: "Earl Grey", grams: 200 }]); -console.log(order2.getSummary()); - -console.log(shop.getReport()); \ No newline at end of file