From 24a79fa036e05cabe7d7bf092048c98f10ca3682 Mon Sep 17 00:00:00 2001 From: Carlos Abreu Date: Sat, 28 Mar 2026 20:08:54 +0000 Subject: [PATCH 1/7] Committed alarmclock.js and index.html --- Sprint-3/alarmclock/alarmclock.js | 65 ++++++++++++++++++++++++++++++- Sprint-3/alarmclock/index.html | 4 +- 2 files changed, 66 insertions(+), 3 deletions(-) diff --git a/Sprint-3/alarmclock/alarmclock.js b/Sprint-3/alarmclock/alarmclock.js index 6ca81cd3b..99a137788 100644 --- a/Sprint-3/alarmclock/alarmclock.js +++ b/Sprint-3/alarmclock/alarmclock.js @@ -1,4 +1,52 @@ -function setAlarm() {} +let timerInterval = null; +let currentTime = 0; + +function setAlarm() { + // Clear any existing timer + if (timerInterval) { + clearInterval(timerInterval); + timerInterval = null; + } + + // Get the input value + const input = document.getElementById("alarmSet"); + let totalSeconds = parseInt(input.value); + + // Validate input (if empty or invalid, default to 0) + if (isNaN(totalSeconds)) { + totalSeconds = 0; + } + + currentTime = totalSeconds; + + // Update the display + updateTimeDisplay(currentTime); + + // Start the countdown + timerInterval = setInterval(() => { + if (currentTime > 0) { + currentTime--; + updateTimeDisplay(currentTime); + + // Check if timer reached zero + if (currentTime === 0) { + clearInterval(timerInterval); + timerInterval = null; + playAlarm(); + // Change background color + document.body.style.backgroundColor = "red"; + } + } + }, 1000); +} + +function updateTimeDisplay(totalSeconds) { + const minutes = Math.floor(totalSeconds / 60); + const seconds = totalSeconds % 60; + const formattedTime = `${minutes.toString().padStart(2, "0")}:${seconds.toString().padStart(2, "0")}`; + const heading = document.getElementById("timeRemaining"); + heading.textContent = `Time Remaining: ${formattedTime}`; +} // DO NOT EDIT BELOW HERE @@ -16,10 +64,25 @@ function setup() { function playAlarm() { audio.play(); + // Play continuously by looping + audio.loop = true; } function pauseAlarm() { audio.pause(); + audio.currentTime = 0; + // Reset background color when alarm is stopped + document.body.style.backgroundColor = ""; + + // Clear any ongoing timer + if (timerInterval) { + clearInterval(timerInterval); + timerInterval = null; + } + + // Reset display to 00:00 + currentTime = 0; + updateTimeDisplay(0); } window.onload = setup; diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index 48e2e80d9..66748001e 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -1,10 +1,10 @@ - + - Title here + Alarm clock app
From ce536075dd7747804a5655f26cabbb5ef80257e4 Mon Sep 17 00:00:00 2001 From: CJ Yuan Date: Tue, 17 Mar 2026 15:45:27 +0000 Subject: [PATCH 2/7] Clarify dedupe() should return a new array --- Sprint-1/implement/dedupe.test.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Sprint-1/implement/dedupe.test.js b/Sprint-1/implement/dedupe.test.js index 23e0f8638..d7c8e3d8e 100644 --- a/Sprint-1/implement/dedupe.test.js +++ b/Sprint-1/implement/dedupe.test.js @@ -6,9 +6,9 @@ Dedupe Array In this kata, you will need to deduplicate the elements of an array -E.g. dedupe(['a','a','a','b','b','c']) target output: ['a','b','c'] -E.g. dedupe([5, 1, 1, 2, 3, 2, 5, 8]) target output: [5, 1, 2, 3, 8] -E.g. dedupe([1, 2, 1]) target output: [1, 2] +E.g. dedupe(['a','a','a','b','b','c']) returns ['a','b','c'] +E.g. dedupe([5, 1, 1, 2, 3, 2, 5, 8]) returns [5, 1, 2, 3, 8] +E.g. dedupe([1, 2, 1]) returns [1, 2] */ // Acceptance Criteria: @@ -22,6 +22,7 @@ test.todo("given an empty array, it returns an empty array"); // When passed to the dedupe function // Then it should return a copy of the original array -// Given an array with strings or numbers +// Given an array of strings or numbers // When passed to the dedupe function -// Then it should remove the duplicate values, preserving the first occurence of each element +// Then it should return a new array with duplicates removed while preserving the +// first occurrence of each element from the original array. From 04358e7bafc2da167ef83f8384a41c0258b21d72 Mon Sep 17 00:00:00 2001 From: Carlos Abreu Date: Tue, 31 Mar 2026 14:59:16 +0100 Subject: [PATCH 3/7] gitignore committed --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8ee70353f..261c79153 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules **/.DS_Store .idea package-lock.json +package.json From 99099b1d520589116bfea9638b3ab3cd9b9a61e8 Mon Sep 17 00:00:00 2001 From: Carlos Abreu Date: Tue, 31 Mar 2026 17:00:32 +0100 Subject: [PATCH 4/7] Added wildcard ** for gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 261c79153..781d487a3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ node_modules **/.DS_Store .idea package-lock.json -package.json +**package.json From 4ce84857d0adcb4f9c56e4cd633f696abc553063 Mon Sep 17 00:00:00 2001 From: Carlos Abreu Date: Wed, 1 Apr 2026 21:29:40 +0100 Subject: [PATCH 5/7] fix: correct .gitignore synatx for package.json exclusion --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 781d487a3..c802825ff 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ node_modules **/.DS_Store .idea package-lock.json -**package.json +**/package.json From 5228f85f63c63cd3c2a073491bdd13b588d738da Mon Sep 17 00:00:00 2001 From: Carlos Abreu Date: Wed, 1 Apr 2026 21:46:06 +0100 Subject: [PATCH 6/7] Fix: changed doctype to capital letter --- Sprint-3/alarmclock/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sprint-3/alarmclock/index.html b/Sprint-3/alarmclock/index.html index 66748001e..ff2d3b453 100644 --- a/Sprint-3/alarmclock/index.html +++ b/Sprint-3/alarmclock/index.html @@ -1,4 +1,4 @@ - + From d4fbe4511199c7f41c28d61fa05d0c40afff9f99 Mon Sep 17 00:00:00 2001 From: Carlos Abreu Date: Wed, 1 Apr 2026 22:23:45 +0100 Subject: [PATCH 7/7] Added trailing slash at end of some entries in dot gitignore --- .gitignore | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index c802825ff..15219736d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ -node_modules +node_modules/ .DS_Store -.vscode -**/.DS_Store -.idea +.vscode/ +.idea/ package-lock.json +package.json **/package.json