From 28a696fb75a585c0a0b6845ebd495d3edf2c06a2 Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Tue, 7 Jul 2026 07:29:16 +0100 Subject: [PATCH 1/9] reverted to original --- Sprint-1/fix/median.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index b22590bc6..a1e52d497 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -6,9 +6,31 @@ // 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; + if (!Array.isArray(list)) { + return null; + } + if (list.length === 0) { + return null; + } + const numbersOnly = list.filter((item) => typeof item === "number"); + if (numbersOnly.length === 0) { + return null; + } + const sorted = [...numbersOnly].sort((a, b) => a - b); + const middleIndex = Math.floor(sorted.length / 2); + if (sorted.length % 2 === 0) { + const median = (sorted[middleIndex - 1] + sorted[middleIndex]) / 2; + return median; + } + return sorted[middleIndex]; } +/* +const middleIndex = Math.floor(list.length / 2); +const median = list.splice(middleIndex, 1)[0]; +return median; +*/ module.exports = calculateMedian; +/* + + */ From cff19af51abaccc5438b6f625a4565711f1ac370 Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Tue, 7 Jul 2026 07:45:43 +0100 Subject: [PATCH 2/9] reverted to original --- Sprint-1/fix/median.js | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/Sprint-1/fix/median.js b/Sprint-1/fix/median.js index a1e52d497..b22590bc6 100644 --- a/Sprint-1/fix/median.js +++ b/Sprint-1/fix/median.js @@ -6,31 +6,9 @@ // or 'list' has mixed values (the function is expected to sort only numbers). function calculateMedian(list) { - if (!Array.isArray(list)) { - return null; - } - if (list.length === 0) { - return null; - } - const numbersOnly = list.filter((item) => typeof item === "number"); - if (numbersOnly.length === 0) { - return null; - } - const sorted = [...numbersOnly].sort((a, b) => a - b); - const middleIndex = Math.floor(sorted.length / 2); - if (sorted.length % 2 === 0) { - const median = (sorted[middleIndex - 1] + sorted[middleIndex]) / 2; - return median; - } - return sorted[middleIndex]; + const middleIndex = Math.floor(list.length / 2); + const median = list.splice(middleIndex, 1)[0]; + return median; } -/* -const middleIndex = Math.floor(list.length / 2); -const median = list.splice(middleIndex, 1)[0]; -return median; -*/ module.exports = calculateMedian; -/* - - */ From 817f8118eb6c8d3e8479aed87e5f8437b68f6679 Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Mon, 3 Aug 2026 07:36:48 +0100 Subject: [PATCH 3/9] implemented the quote generator based on the instructions provided --- Sprint-3/quote-generator/index.html | 32 +++++++++++-------- Sprint-3/quote-generator/quotes.js | 7 +++++ Sprint-3/quote-generator/style.css | 49 ++++++++++++++++++++++++++++- 3 files changed, 74 insertions(+), 14 deletions(-) diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index 30b434bcf..bce58ef1a 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -1,15 +1,21 @@ - - - - Title here - - - -

hello there

-

-

- - - + + + + + Quote Generator + + + + + +
+

Quote of the Day

+

"this is the quote"

+

- Author Name

+
+ + + + \ No newline at end of file diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index 4a4d04b72..c218c7111 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -1,3 +1,10 @@ +function generateQuote() { + const randomQuote = pickFromArray(quotes); + document.getElementById("quote").textContent = `"${randomQuote.quote}"`; + document.getElementById("author").textContent = `- ${randomQuote.author}`; +} +generateQuote(); + // DO NOT EDIT BELOW HERE // pickFromArray is a function which will return one item, at diff --git a/Sprint-3/quote-generator/style.css b/Sprint-3/quote-generator/style.css index 63cedf2d2..c4c7a3f86 100644 --- a/Sprint-3/quote-generator/style.css +++ b/Sprint-3/quote-generator/style.css @@ -1 +1,48 @@ -/** Write your CSS in here **/ +body { + margin: 0; + padding: 0; + justify-content: center; + font-family: Arial, sans-serif; + background-color: #d4b4ec; +} + +.quote-box { + margin: 50px auto; + width: 80%; + max-width: 600px; + padding: 30px; + text-align: center; + background-color: #fff; + border-radius: 10px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); +} + +h1 { + margin-bottom: 25px; +} +#quote { + min-height: 60px; + margin-bottom: 25px; + font-size: 1.5em; + line-height: 1.5; + font-style: italic; +} + +button { + display: block; + margin: 20px auto; + font-weight: bold; + padding: 12px 20px; + font-size: 1.5em; + background-color: rgba(96, 55, 92, 0.2); + color: #232b2e; + border: none; + cursor: pointer; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2); +} + +button:hover { + background-color: rgba(53, 31, 51, 0.2); + font-weight: bold; + text-shadow: 0 1px 2px white; +} From 0e93ef0262599f33a6a3777c84f318540928229b Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Fri, 7 Aug 2026 18:31:33 +0100 Subject: [PATCH 4/9] added a script tag to index.html to include quotes.js --- Sprint-3/quote-generator/quotes.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Sprint-3/quote-generator/quotes.js b/Sprint-3/quote-generator/quotes.js index c218c7111..d01306323 100644 --- a/Sprint-3/quote-generator/quotes.js +++ b/Sprint-3/quote-generator/quotes.js @@ -1,10 +1,3 @@ -function generateQuote() { - const randomQuote = pickFromArray(quotes); - document.getElementById("quote").textContent = `"${randomQuote.quote}"`; - document.getElementById("author").textContent = `- ${randomQuote.author}`; -} -generateQuote(); - // DO NOT EDIT BELOW HERE // pickFromArray is a function which will return one item, at @@ -498,3 +491,9 @@ const quotes = [ ]; // call pickFromArray with the quotes array to check you get a random quote +function generateQuote() { + const randomQuote = pickFromArray(quotes); + document.getElementById("quote").textContent = `"${randomQuote.quote}"`; + document.getElementById("author").textContent = `- ${randomQuote.author}`; +} +generateQuote(); From 1ce772d2dc2ddbc9ba77fd3ae6d02d5f90acfb93 Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Fri, 7 Aug 2026 18:32:13 +0100 Subject: [PATCH 5/9] reverted some changes in quotes.js and index.html to fix the issue of quotes not being displayed on page load --- Sprint-3/quote-generator/index.html | 1 + Sprint-3/quote-generator/package.json | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Sprint-3/quote-generator/index.html b/Sprint-3/quote-generator/index.html index bce58ef1a..31c26b136 100644 --- a/Sprint-3/quote-generator/index.html +++ b/Sprint-3/quote-generator/index.html @@ -16,6 +16,7 @@

Quote of the Day

- Author Name

+ \ No newline at end of file diff --git a/Sprint-3/quote-generator/package.json b/Sprint-3/quote-generator/package.json index 0f6f98917..39c2ccfdb 100644 --- a/Sprint-3/quote-generator/package.json +++ b/Sprint-3/quote-generator/package.json @@ -13,5 +13,8 @@ "bugs": { "url": "https://github.com/CodeYourFuture/CYF-Coursework-Template/issues" }, - "homepage": "https://github.com/CodeYourFuture/CYF-Coursework-Template#readme" + "homepage": "https://github.com/CodeYourFuture/CYF-Coursework-Template#readme", + "devDependencies": { + "@testing-library/jest-dom": "^6.9.1" + } } From fd618b8dc09c5134ab8f738b2617032442440a8b Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Fri, 7 Aug 2026 19:47:05 +0100 Subject: [PATCH 6/9] implemented the alarm clock function based on the specified instructions and added flashing effect --- Sprint-3/alarmclock/alarmclock.js | 95 ++++++++++++++++++++++++++++++- Sprint-3/alarmclock/index.html | 37 ++++++------ 2 files changed, 114 insertions(+), 18 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 6ca81cd3b..698eca0ec 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,4 +1,96 @@ -function setAlarm() {} +// This variable will store the interval so we can stop it later +let flashInterval; + +// This function makes the background flash red and white +function startFlashing() { + let isRed = false; // keeps track of which color we should show + + flashInterval = setInterval(function () { + if (isRed) { + document.body.style.backgroundColor = "white"; + } else { + document.body.style.backgroundColor = "red"; + } + + // Switch the color for next time + isRed = !isRed; + }, 500); // run every half second +} + +// This function stops the flashing and resets the background +function stopFlashing() { + clearInterval(flashInterval); // stop the flashing interval + document.body.style.backgroundColor = "white"; // reset background +} + +function setAlarm() { + // get the value of the input + const input = document.getElementById("alarmSet").value; + + // If nothing was typed, exit the function + if (!input) { + return; + } + + let totalSeconds; + + // If the user typed something like "2:21" + if (input.includes(":")) { + // Split into minutes and seconds + const parts = input.split(":"); + const minutes = Number(parts[0]); + const seconds = Number(parts[1]); + + // Convert everything into total seconds + totalSeconds = minutes * 60 + seconds; + } else { + // Otherwise treat the input as normal seconds + totalSeconds = Number(input); + } + + // This is the countdown number that will go down every second + let timeLeft = totalSeconds; + + // If a previous timer was running, stop it + if (window.countdownTimer) { + clearInterval(window.countdownTimer); + } + + // A simple helper to turn seconds into MM:SS format + function formatTime(seconds) { + const mins = Math.floor(seconds / 60); + const secs = seconds % 60; + + // Make sure both numbers always have two digits + const paddedMins = String(mins).padStart(2, "0"); + const paddedSecs = String(secs).padStart(2, "0"); + + return `${paddedMins}:${paddedSecs}`; + } + + // Show the starting time immediately + document.getElementById("timeRemaining").innerText = + `Time Remaining: ${formatTime(timeLeft)}`; + + // Start the countdown — runs every 1000ms (1 second) + window.countdownTimer = setInterval(() => { + timeLeft--; // reduce by 1 second + + // Update the heading each second + document.getElementById("timeRemaining").innerText = + `Time Remaining: ${formatTime(timeLeft)}`; + + // When the timer reaches zero + if (timeLeft <= 0) { + clearInterval(window.countdownTimer); // stop the countdown + clearInterval(flashInterval); // stop the flashing if it was running + document.getElementById("timeRemaining").innerText = + `Time Remaining: 00:00`; + playAlarm(); // play the alarm sound + startFlashing(); // start flashing the background + } + }, 1000); +} // DO NOT EDIT BELOW HERE @@ -11,6 +103,7 @@ function setup() { document.getElementById("stop").addEventListener("click", () => { pauseAlarm(); + stopFlashing(); // stop flashing if running }); } diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index 48e2e80d9..d54f9f4a0 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -1,20 +1,23 @@ - - - - - Title here - - -
-

Time Remaining: 00:00

- - - - -
- - - + + + + + Alarm Clock + + + +
+

Time Remaining: 00:00

+ + + + + +
+ + + + \ No newline at end of file From 8831a391abff44a58d9ae23079d5eb38c9bb09ba Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Fri, 7 Aug 2026 20:00:18 +0100 Subject: [PATCH 7/9] reverted to original --- Sprint-3/alarmclock/alarmclock.js | 95 +------------------------------ Sprint-3/alarmclock/index.html | 2 +- 2 files changed, 2 insertions(+), 95 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 698eca0ec..6ca81cd3b 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,96 +1,4 @@ -// This variable will store the interval so we can stop it later -let flashInterval; - -// This function makes the background flash red and white -function startFlashing() { - let isRed = false; // keeps track of which color we should show - - flashInterval = setInterval(function () { - if (isRed) { - document.body.style.backgroundColor = "white"; - } else { - document.body.style.backgroundColor = "red"; - } - - // Switch the color for next time - isRed = !isRed; - }, 500); // run every half second -} - -// This function stops the flashing and resets the background -function stopFlashing() { - clearInterval(flashInterval); // stop the flashing interval - document.body.style.backgroundColor = "white"; // reset background -} - -function setAlarm() { - // get the value of the input - const input = document.getElementById("alarmSet").value; - - // If nothing was typed, exit the function - if (!input) { - return; - } - - let totalSeconds; - - // If the user typed something like "2:21" - if (input.includes(":")) { - // Split into minutes and seconds - const parts = input.split(":"); - const minutes = Number(parts[0]); - const seconds = Number(parts[1]); - - // Convert everything into total seconds - totalSeconds = minutes * 60 + seconds; - } else { - // Otherwise treat the input as normal seconds - totalSeconds = Number(input); - } - - // This is the countdown number that will go down every second - let timeLeft = totalSeconds; - - // If a previous timer was running, stop it - if (window.countdownTimer) { - clearInterval(window.countdownTimer); - } - - // A simple helper to turn seconds into MM:SS format - function formatTime(seconds) { - const mins = Math.floor(seconds / 60); - const secs = seconds % 60; - - // Make sure both numbers always have two digits - const paddedMins = String(mins).padStart(2, "0"); - const paddedSecs = String(secs).padStart(2, "0"); - - return `${paddedMins}:${paddedSecs}`; - } - - // Show the starting time immediately - document.getElementById("timeRemaining").innerText = - `Time Remaining: ${formatTime(timeLeft)}`; - - // Start the countdown — runs every 1000ms (1 second) - window.countdownTimer = setInterval(() => { - timeLeft--; // reduce by 1 second - - // Update the heading each second - document.getElementById("timeRemaining").innerText = - `Time Remaining: ${formatTime(timeLeft)}`; - - // When the timer reaches zero - if (timeLeft <= 0) { - clearInterval(window.countdownTimer); // stop the countdown - clearInterval(flashInterval); // stop the flashing if it was running - document.getElementById("timeRemaining").innerText = - `Time Remaining: 00:00`; - playAlarm(); // play the alarm sound - startFlashing(); // start flashing the background - } - }, 1000); -} +function setAlarm() {} // DO NOT EDIT BELOW HERE @@ -103,7 +11,6 @@ function setup() { document.getElementById("stop").addEventListener("click", () => { pauseAlarm(); - stopFlashing(); // stop flashing if running }); } diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index d54f9f4a0..df9ca334b 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -5,7 +5,7 @@ - Alarm Clock + Title here From 6bac005b097ba80580553c1cdfdaf7ca8b51d5e1 Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Fri, 7 Aug 2026 20:04:03 +0100 Subject: [PATCH 8/9] reverted to original --- Sprint-3/alarmclock/index (1).html | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Sprint-3/alarmclock/index (1).html diff --git a/Sprint-3/alarmclock/index (1).html b/Sprint-3/alarmclock/index (1).html new file mode 100644 index 000000000..48e2e80d9 --- /dev/null +++ b/Sprint-3/alarmclock/index (1).html @@ -0,0 +1,20 @@ + + + + + + + Title here + + +
+

Time Remaining: 00:00

+ + + + + +
+ + + From b4cfec11c769534c2faece818e654b1fc9070207 Mon Sep 17 00:00:00 2001 From: Yonatan Teklemariam Date: Fri, 7 Aug 2026 20:06:17 +0100 Subject: [PATCH 9/9] reverted to original and removed extra index.html file --- Sprint-3/alarmclock/index (1).html | 20 ---------------- Sprint-3/alarmclock/index.html | 37 ++++++++++++++---------------- 2 files changed, 17 insertions(+), 40 deletions(-) delete mode 100644 Sprint-3/alarmclock/index (1).html diff --git a/Sprint-3/alarmclock/index (1).html b/Sprint-3/alarmclock/index (1).html deleted file mode 100644 index 48e2e80d9..000000000 --- a/Sprint-3/alarmclock/index (1).html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - Title here - - -
-

Time Remaining: 00:00

- - - - - -
- - - diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index df9ca334b..48e2e80d9 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -1,23 +1,20 @@ + + + + + Title here + + +
+

Time Remaining: 00:00

+ + - - - - - Title here - - - -
-

Time Remaining: 00:00

- - - - - -
- - - - \ No newline at end of file + + +
+ + +