Skip to content

London | 26 ITP January | Mouawia Elkhalifa | Sprint 3 | Alarm Clock#1087

Closed
MouawiaElkhalifa wants to merge 3 commits intoCodeYourFuture:mainfrom
MouawiaElkhalifa:sprint-3
Closed

London | 26 ITP January | Mouawia Elkhalifa | Sprint 3 | Alarm Clock#1087
MouawiaElkhalifa wants to merge 3 commits intoCodeYourFuture:mainfrom
MouawiaElkhalifa:sprint-3

Conversation

@MouawiaElkhalifa
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

In this PR, I have completed the Alarm Clock assignment for Sprint 3.

@MouawiaElkhalifa MouawiaElkhalifa added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 24, 2026
Copy link
Copy Markdown
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

  • Code works fine if a user only clicks the "Set Alarm" button once.
    However, if the user enters a time and then clicks the "Set Alarm" button multiple times, the countdown clock will not display properly.
    Can you fix the issue?

  • You missed updating index.html according to an instruction in readme.md.

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 Apr 5, 2026
@MouawiaElkhalifa MouawiaElkhalifa added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 5, 2026
Copy link
Copy Markdown
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

(1) Currently when starting a new countdown, the application does not always return to a clean initial state, which can lead to inconsistent behavior between runs. (Hint: a user may not click the "Stop" button first before starting a new count down.)

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

(2) Can you make the "Stop" button to also stop the count down? You can add another "click" event listener to the button to avoid modifying the original code.

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
const timeDisplay = document.getElementById("timeRemaining");

if (isNaN(secondsLeft) || secondsLeft <= 0) {
timeDisplay.innerText = "Time Remaining: 00:00";
Copy link
Copy Markdown
Contributor

@cjyuan cjyuan Apr 6, 2026

Choose a reason for hiding this comment

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

Could consider calling updateDisplay(0) on line 8, trading few milliseconds for simpler code, and keep the logic of displaying time in one place.

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
I added a resetAlarm() function so every new countdown starts from a clean state.
I added another click listener to the Stop button so it also clears the active countdown.
I also moved the display formatting into updateDisplay() to keep the time rendering in one place.

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 6, 2026
@MouawiaElkhalifa MouawiaElkhalifa added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 6, 2026
Copy link
Copy Markdown
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

Changes look good. Well done.

Comment on lines +61 to +64
if (countdown !== null) {
clearInterval(countdown);
countdown = null;
}
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.

Could also consider using resetAlarm as the callback, trading slight inefficiency for simplicity (and to keep the logic of resetting the alarm in one place). The code won't break when pauseAlarm() is called twice.

@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. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Apr 6, 2026
@illicitonion
Copy link
Copy Markdown
Member

Closing PR because the January ITP run has finished. Feel free to re-open if you're still working on it.

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.

3 participants