From 53fa90f23e51a0aecf94e5be7db577997e87a7b6 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Sat, 7 Mar 2026 14:25:25 +0200 Subject: [PATCH 1/4] implement correct median calculation --- Sprint-1/fix/median.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index b22590bc6..f7d2fd653 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -6,9 +6,21 @@ // or 'list' has mixed values (the function is expected to sort only numbers). function calculateMedian(list) { - const middleIndex = Math.floor(list.length / 2); - const median = list.splice(middleIndex, 1)[0]; - return median; + // Filter out non-numeric values and sort the remaining numbers + const numbers = list + .filter((x) => typeof x === "number" && !isNaN(x)) + .sort((a, b) => a - b); + + if (numbers.length === 0) { + return null; + } + + const mid = Math.floor(numbers.length / 2); + if (numbers.length % 2 === 0) { + return (numbers[mid - 1] + numbers[mid]) / 2; + } else { + return numbers[mid]; + } } module.exports = calculateMedian; From 4e4fa074f4cf50fe7f299858cb9fb365d5f422bc Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Fri, 17 Apr 2026 13:16:07 +0200 Subject: [PATCH 2/4] Revert "implement correct median calculation" This reverts commit 53fa90f23e51a0aecf94e5be7db577997e87a7b6. --- Sprint-1/fix/median.js | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index f7d2fd653..b22590bc6 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -6,21 +6,9 @@ // or 'list' has mixed values (the function is expected to sort only numbers). function calculateMedian(list) { - // Filter out non-numeric values and sort the remaining numbers - const numbers = list - .filter((x) => typeof x === "number" && !isNaN(x)) - .sort((a, b) => a - b); - - if (numbers.length === 0) { - return null; - } - - const mid = Math.floor(numbers.length / 2); - if (numbers.length % 2 === 0) { - return (numbers[mid - 1] + numbers[mid]) / 2; - } else { - return numbers[mid]; - } + const middleIndex = Math.floor(list.length / 2); + const median = list.splice(middleIndex, 1)[0]; + return median; } module.exports = calculateMedian; From 22b6c5cc73165111e97793dc032750252e796db7 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Fri, 17 Apr 2026 15:49:22 +0200 Subject: [PATCH 3/4] feat: implement quote generator --- Sprint-3/quote-generator/index.html | 6 +++--- Sprint-3/quote-generator/quotes.js | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 30b434bcf..7952b4cd7 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -1,13 +1,13 @@ - + - Title here + Quote Generator -

hello there

+

Quote Generator

diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 4a4d04b72..ca742f8a9 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -1,3 +1,15 @@ +const quoteP = document.querySelector("#quote"); +const authorP = document.querySelector("#author"); +const button = document.querySelector("#new-quote"); + +function displayQuote() { + const randomQuote = pickFromArray(quotes); + quoteP.innerText = randomQuote.quote; + authorP.innerText = randomQuote.author; +} + +button.addEventListener("click", displayQuote); + // DO NOT EDIT BELOW HERE // pickFromArray is a function which will return one item, at @@ -491,3 +503,4 @@ const quotes = [ ]; // call pickFromArray with the quotes array to check you get a random quote +displayQuote(); From 05f19b9304ca8ef5201373749560887157a0f1c4 Mon Sep 17 00:00:00 2001 From: Pretty Taruvinga Date: Fri, 17 Apr 2026 16:39:44 +0200 Subject: [PATCH 4/4] Add CSS styling to quote generator and link stylesheet in HTML --- Sprint-3/quote-generator/index.html | 1 + Sprint-3/quote-generator/style.css | 64 ++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 7952b4cd7..81342bc2b 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -4,6 +4,7 @@ Quote Generator + diff --git a/Sprint-3/quote-generator/style.css b/Sprint-3/quote-generator/style.css index 63cedf2d2..f4612f9f9 100644 --- a/Sprint-3/quote-generator/style.css +++ b/Sprint-3/quote-generator/style.css @@ -1 +1,63 @@ -/** Write your CSS in here **/ +body { + margin: 0; + padding: 0; + font-family: "Poppins", sans-serif; + background: linear-gradient(135deg, #ff9ecf, #ffc3a0); + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + height: 100vh; +} + +h1 { + color: white; + margin-bottom: 20px; +} + +#quote { + background: #fff0f6; + padding: 2rem; + border-radius: 20px 20px 0 0; + width: 60%; + max-width: 700px; + color: #d63384; + font-size: 1.6rem; + position: relative; +} + +#quote::before { + content: "❝"; + position: absolute; + left: 15px; + top: 5px; + font-size: 3rem; + color: #ff85c1; +} + +#author { + background: #fff0f6; + width: 60%; + max-width: 700px; + padding: 1rem 2rem; + text-align: right; + color: #c2185b; + border-radius: 0 0 20px 20px; +} + +#new-quote { + margin-top: 20px; + background: #ff85c1; + color: white; + border: none; + padding: 0.7rem 1.4rem; + border-radius: 20px; + cursor: pointer; + font-size: 0.95rem; + transition: all 0.3s ease; +} + +#new-quote:hover { + background: #ff4fa3; + transform: translateY(-2px) scale(1.05); +}