Skip to content

Conversation

@Tarawally
Copy link

Learners, PR Template

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 countdown timer displaying time in mm:ss format
  • Added alarm sound and flashing red background when timer reaches zero
  • Enabled stop button to pause alarm and remove visual effects

@github-actions
Copy link

Your PR's title isn't in the expected format.

Please check the expected title format, and update yours to match.

Reason: Wrong number of parts separated by |s

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@Tarawally Tarawally changed the title Feat/alarmclock London | 25-ITP-Sept | Samuel Tarawally | Sprint 3 | Alarm Clock Dec 13, 2025
@Tarawally Tarawally added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 13, 2025
Comment on lines +13 to +23
let formattedMinutes = `${minutes}`;
if (minutes < 10) {
formattedMinutes = `0${minutes}`;
}

let formattedSeconds = `${seconds}`;
if (seconds < 10) {
formattedSeconds = `0${seconds}`;
}

return `Time Remaining: ${formattedMinutes}:${formattedSeconds}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Code on lines 13-23 could be simplified by using String.prototype.padStart().

* Updates the display and checks if the alarm should sound.
*/
function updateTime() {
const titleElement = document.getElementById("timeRemaining");
Copy link
Contributor

Choose a reason for hiding this comment

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

We could perform the operation on line 30 only once and reuse the retrieved DOM element repeatedly (to improve performance).

* Initialises the alarm countdown.
*/
function setAlarm() {
if (alarmTimerIdentifier) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Once set, alarmTimerIdentifier is never reset. So this condition will only be false the first time setAlarm() is called. Well, do we need to check or reset this variable?

Comment on lines +68 to +69
const titleElement = document.getElementById("timeRemaining");
titleElement.innerText = formatTime(timeRemainingInSeconds);
Copy link
Contributor

Choose a reason for hiding this comment

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

These two statements and the statements on lines 30, 33 are identical. This is usually a hint that we could factor out the code into a function, and then just call the function to perform the corresponding task.

Comment on lines +71 to +74
alarmTimerIdentifier = setInterval(() => {
updateTime();
}, ONE_SECOND_IN_MILLISECONDS);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The alarm will sound one second afterward when the input is either 0 or 1 second -- it is a bit inconsistent. Can you improve the consistency?

@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 Dec 13, 2025
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