Skip to content

London | 26-ITP-Jan | Xuanming Hu | Sprint 3 | Alarm Clock App#1115

Open
Samual-Hu wants to merge 3 commits intoCodeYourFuture:mainfrom
Samual-Hu:coursework/sprint-3-alarmclock
Open

London | 26-ITP-Jan | Xuanming Hu | Sprint 3 | Alarm Clock App#1115
Samual-Hu wants to merge 3 commits intoCodeYourFuture:mainfrom
Samual-Hu:coursework/sprint-3-alarmclock

Conversation

@Samual-Hu
Copy link
Copy Markdown

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 setAlarm with setInterval.
  • Handled time formatting (minutes:seconds) using padStart.
  • Ensured immediate DOM update upon click and cleared the interval when the timer ends.

Questions

N/A

@Samual-Hu Samual-Hu added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 27, 2026
@Luro91 Luro91 added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Apr 4, 2026

let timeRemaining = parseInt(inputElement.value, 10) || 0;

clearInterval(countdownInterval);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice that the old interval is cleared when the alarm is set again

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.

Thanks

countdownInterval = setInterval(() => {
timeRemaining--;

if (timeRemaining < 0) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

When does the alarm start when you are comparing for < 0 ?

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.

Using '< 0' makes the alarm trigger one second late. I have updated it to '<= 0'. Thanks

@Luro91 Luro91 added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Apr 4, 2026
@Samual-Hu Samual-Hu 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 Apr 7, 2026
@Samual-Hu
Copy link
Copy Markdown
Author

Hi @Luro91, I have updated the code based on your feedback.

@Luro91 Luro91 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 7, 2026
Comment on lines +23 to +24
clearInterval(countdownInterval);
playAlarm();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What does the countdown show when the alarm plays?

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.

Because updateDisplay() was inside the else block, the screen would freeze at 00:01 while the alarm played, never actually showing 00:00.

@Samual-Hu Samual-Hu 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 Apr 7, 2026
@Samual-Hu
Copy link
Copy Markdown
Author

Hi @Luro91 , I have updated the display first before checking the timeRemaining <= 0 condition. Thanks for pointing this out.

Copy link
Copy Markdown

@Luro91 Luro91 left a comment

Choose a reason for hiding this comment

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

Well done the code works as expected

@Luro91 Luro91 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 Apr 7, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants