Skip to content

Cape Town | 26-ITP-Sept | Leigh Ross | Sprint 3 | Build an alarm clock app - #1511

Open
leigh-ross wants to merge 9 commits into
CodeYourFuture:mainfrom
leigh-ross:coursework/alarm-clock-app
Open

leigh-ross wants to merge 9 commits into
CodeYourFuture:mainfrom
leigh-ross:coursework/alarm-clock-app

Conversation

@leigh-ross

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

Task code

CYF-1098

Changelist

  • Setup: Changed the page title to "Alarm clock app" and added initial styling for the layout and buttons.
  • Time Formatting: Implemented a function to convert raw seconds into a standard MM:SS format (e.g., 01:10).
  • Countdown Logic: Built the setAlarm function to start the countdown timer, update the screen every second, and trigger the audio alarm when it reaches 00:00.
  • Visual Flair: Added custom background images (hamsters) that change when the alarm is set, goes off, and stops.
  • Flashing Effect: Added an interval to toggle a red background class on the clock box when the alarm rings (limited to 20 flashes so it doesn't loop forever). The alarm sound continues playing until stopped.

@leigh-ross leigh-ross added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 11, 2026
@LonMcGregor LonMcGregor added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Nov 16, 2026
Comment thread Sprint-3/alarmclock/alarmclock.js Resolved
Comment thread Sprint-3/alarmclock/alarmclock.js Resolved
@cyf-ai-code-reviewer cyf-ai-code-reviewer Bot 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 Nov 16, 2026
@cyf-ai-code-reviewer

Copy link
Copy Markdown

The CYF AI review has left comments. It will only review a PR one time. When you have addressed these comments, please request review again and a volunteer will take a look.

…s the flashing bg, ensure that min time to input is still 0 (no negative numbers), remove red-bg class when alarm is stopped. format using prettier
@leigh-ross leigh-ross added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 18, 2026
@hackertainment hackertainment 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. Reviewed Volunteer to add when completing a review with trainee action still to take. labels Nov 27, 2026

@hackertainment hackertainment left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your program runs correctly. However, it actually took me quite a while to understand your logic. Since you use two timers (for counting down seconds and flashing respectively) and one nested inside another, it makes the code a bit hard to read and maintain. If you wish, please book a mentored coding session with a volunteer to learn more about the design/planning process. I would mark this PR as completed. Thank you.

Comment on lines +87 to +93
document.getElementById("stop").addEventListener("click", () => {
document.body.style.backgroundImage = "url('alarmsethamster.jfif')";
document.body.style.backgroundPosition = "center";
clearInterval(countdownTimer);
clearInterval(flashTimer);
document.querySelector(".centre").classList.remove("red-bg");
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The starter code has already listened the click event for the stop element. Adding another listener may cause race condition. Due to the limitation of not modifying starter code, you may consider creating another HTML element for your listener - still not ideal though.

clearInterval(countdownTimer);
clearInterval(flashTimer);

pauseAlarm();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good use of existing function provided :-)

@hackertainment hackertainment added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Nov 27, 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.

3 participants