Skip to content

Glasgow | 26-ITP-May | Francesco Romano Monda | Sprint 3 | Alarm Clock App - #1370

Open
fromonda wants to merge 5 commits into
CodeYourFuture:mainfrom
fromonda:coursework/sprint-3/alarm-clock-app
Open

Glasgow | 26-ITP-May | Francesco Romano Monda | Sprint 3 | Alarm Clock App#1370
fromonda wants to merge 5 commits into
CodeYourFuture:mainfrom
fromonda:coursework/sprint-3/alarm-clock-app

Conversation

@fromonda

@fromonda fromonda commented Aug 3, 2026

Copy link
Copy Markdown

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

  • Updated the page title in index.html to "Alarm clock app".
  • Implemented the alarm clock functionality in alarmclock.js.
  • Added functionality for the Set Alarm button to read the user's input and start the countdown.
  • Updated the countdown display to show the remaining time in MM:SS format.
  • Added a timer that decreases the remaining time every second.
  • Implemented the alarm trigger when the countdown reaches 00:00.
  • Added functionality to stop the alarm sound using the Stop Alarm button.
  • Ensured the countdown and alarm behaviour work correctly with the provided test requirements.

@fromonda fromonda added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Data-Groups The name of the module. labels Aug 3, 2026

@cjyuan cjyuan left a comment

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.

Currently when starting a new countdown, the application does not always return to a clean initial state, which can lead to inconsistent behaviour between runs.

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

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
@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 Aug 8, 2026
@fromonda fromonda added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 8, 2026
@fromonda

fromonda commented Aug 8, 2026

Copy link
Copy Markdown
Author

Currently when starting a new countdown, the application does not always return to a clean initial state, which can lead to inconsistent behaviour between runs.

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

I have fixed the Stop Alarm functionality by adding a stopAlarm() function that clears the timer and pauses the alarm.

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
Comment on lines +53 to +54
document.getElementById("set").addEventListener("click", setAlarm);
document.getElementById("stop").addEventListener("click", stopAlarm);

@cjyuan cjyuan Aug 8, 2026

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.

The original code also assigns event listeners (on lines 61-67) to these two buttons. Could you find a way to prevent setAlarm() and pauseAlarm() from being called twice (without modifying the original code)?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I prevented the duplicate calls by adding event listeners in the capture phase and using event.stopImmediatePropagation(). This stops the original event listeners from firing as well, so setAlarm() and pauseAlarm() are each called only once, without modifying the original code below the DO NOT EDIT section.
I hope this resolves the issue and that you can now mark the assignment as complete.

@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 Aug 8, 2026
@fromonda fromonda added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 8, 2026

@cjyuan cjyuan left a comment

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.

Your approach works. All good.

If time permits, do use AI to research the pros and cons of different approaches.

Comment on lines +56 to +63
setButton.addEventListener(
"click",
function (event) {
event.stopImmediatePropagation();
setAlarm();
},
true
);

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.

Why not just let the original code to call setAlarm()?

Comment on lines +65 to +72
stopButton.addEventListener(
"click",
function (event) {
event.stopImmediatePropagation();
stopAlarm();
},
true
);

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.

Given that the original code would call pauseAlarm(), an alternative is to add another event listener that calls only "clearInterval()", and let the original code stop the audio.

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Data-Groups The name of the module. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants