Skip to content

Cape Town | 2026-ITP-Jan | Isaac Abodunrin | Sprint 3 | Grouping data: Alarm Clock#1182

Open
bytesandroses wants to merge 14 commits intoCodeYourFuture:mainfrom
bytesandroses:coursework/Sprint-3/alarm-clock
Open

Cape Town | 2026-ITP-Jan | Isaac Abodunrin | Sprint 3 | Grouping data: Alarm Clock#1182
bytesandroses wants to merge 14 commits intoCodeYourFuture:mainfrom
bytesandroses:coursework/Sprint-3/alarm-clock

Conversation

@bytesandroses
Copy link
Copy Markdown
Member

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Implemented alarm clock functionality and countdown timer logic to

  • set alarm
  • format time correctly
  • display the remaining time as it counts down

@bytesandroses bytesandroses added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 6, 2026

function setAlarm() {
const setTime = document.getElementById("alarmSet").value;
timeRemaining = parseInt(setTime, 10);
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.

Using user input without proper validation and sanitisation can be dangeours.

Currently, some unusual input values can make your app behave abnormally. Can you add code to sanitise them?

Comment on lines +33 to +35
if (timerInterval) {
clearInterval(timerInterval);
}
Copy link
Copy Markdown
Contributor

@cjyuan cjyuan Apr 9, 2026

Choose a reason for hiding this comment

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

The countdown interval is not the only state to be reset.

Hint: a user may not click the "Stop" button first before starting a new count down.

You can also consider introducing a dedicated reset function to return the app to a clean initial state to help ensure consistency.

Comment on lines +16 to +27
function decreaseAlarmTime() {
if (timeRemaining <= 0) {
clearInterval(timerInterval);
timerInterval = null;
timeRemaining = 0;
playAlarm();
return;
}

timeRemaining--;
displayAlarm(timeRemaining);
}
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.

When the countdown reaches 00:00, there is a one second delay before the alarm sound is played. Is this by design?

At line 25, when timeRemaining changes from 1 to 0, the app only changes the display to 00:00. It's only in the next interval, the code on lines 17-22 is executed.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants