Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
7d8f402
Fix calculateMedian implementation so it passes all tests
ChinweP Jul 27, 2026
4649963
Add dedupe implementation that passes all current tests
ChinweP Jul 27, 2026
bb247fd
Implement findMax and add full test coverage for all input scenarios
ChinweP Jul 27, 2026
816b104
Implement sum function and add full test coverage
ChinweP Jul 27, 2026
64a2b80
Refactor includes to use a for-of loop
ChinweP Jul 27, 2026
b057112
Fix address lookup by using correct object property
ChinweP Jul 27, 2026
c76ea74
Fix object iteration by using Object.values() instead of for-of
ChinweP Jul 27, 2026
1743311
Add correct ingredient logging by looping through recipe.ingredients
ChinweP Jul 27, 2026
5ee5409
Add jest tests covering all contains() acceptance criteria
ChinweP Jul 28, 2026
03c6296
Fix invert function and add tests for key-value swapping
ChinweP Jul 29, 2026
3c5b7b9
Complete alarm clock countdown and flashing background
ChinweP Jul 29, 2026
9cf496b
Use jest 28 for Windows compatibility
ChinweP Jul 30, 2026
8e5fb57
Fix revert files from Sprint 1
ChinweP Aug 1, 2026
99e811b
Fix revert files for Sprint 2
ChinweP Aug 1, 2026
6d1118e
Remove obsolete invert tests from Sprint 2
ChinweP Aug 1, 2026
86a7e7d
restore package.json
ChinweP Aug 1, 2026
d724dbc
Update package.json for module-data-groups configuration
ChinweP Aug 1, 2026
2e8421b
Refactor alarm clock logic: validation, reset state, unified display,…
ChinweP Aug 7, 2026
406ef77
Fix alarm reset behavior: ensure alarm pauses and background flashing…
ChinweP Aug 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 60 additions & 1 deletion Sprint-3/alarmclock/alarmclock.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,62 @@
function setAlarm() {}
let intervalId = null;

function setAlarm() {
const input = document.getElementById("alarmSet");
const heading = document.getElementById("timeRemaining");

const value = Number(input.value);
if (!Number.isInteger(value) || value <= 0) {
alert("Please enter a positive whole number of seconds.");
return;
}

resetAlarm();

let remainingSeconds = value;
updateDisplay(remainingSeconds);

intervalId = setInterval(() => {
remainingSeconds -= 1;

if (remainingSeconds > 0) {
updateDisplay(remainingSeconds);
} else {
updateDisplay(0);
clearInterval(intervalId);
playAlarm();
setFlashingBackground(true);
}
}, 1000);
}

function resetAlarm() {
clearInterval(intervalId);
intervalId = null;
updateDisplay(0);
setFlashingBackground(false);
pauseAlarm();
}
Comment thread
cjyuan marked this conversation as resolved.

function updateDisplay(seconds) {
const heading = document.getElementById("timeRemaining");
heading.innerText = `Time Remaining: ${formatTime(seconds)}`;
}

function formatTime(totalSeconds) {
const minutes = Math.floor(totalSeconds / 60);
const seconds = totalSeconds % 60;
const mm = String(minutes).padStart(2, "0");
const ss = String(seconds).padStart(2, "0");
return `${mm}:${ss}`;
}

function setFlashingBackground(isFlashing) {
if (isFlashing) {
document.body.classList.add("flash");
} else {
document.body.classList.remove("flash");
}
}

// DO NOT EDIT BELOW HERE

Expand All @@ -20,6 +78,7 @@ function playAlarm() {

function pauseAlarm() {
audio.pause();
setFlashingBackground(false);
}
Comment on lines 79 to 82

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This work if we could modify the original code. Also, the function is doing more than its name suggest. A better alternative could be:

  • Add another onclick callback to the "Stop" button, and disable the flashing background in the callback.


window.onload = setup;
2 changes: 1 addition & 1 deletion Sprint-3/alarmclock/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Title here</title>
<title>Alarm clock app</title>
</head>
<body>
<div class="centre">
Expand Down
10 changes: 10 additions & 0 deletions Sprint-3/alarmclock/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@
h1 {
text-align: center;
}

.flash {
animation: flash-bg 0.5s infinite alternate;
}

@keyframes flash-bg {
from { background-color: white; }
to { background-color: red; }
}

Loading