Skip to content

London | 26-ITP-Sep | Shirin Panahian | Sprint 3 | Build an alarm clock app - #1578

Open
shirinpanahian wants to merge 8 commits into
CodeYourFuture:mainfrom
shirinpanahian:feat/alarm-clock
Open

shirinpanahian wants to merge 8 commits into
CodeYourFuture:mainfrom
shirinpanahian:feat/alarm-clock

Conversation

@shirinpanahian

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

  • Implemented an alarm clock with a countdown timer.
  • Added input validation for the alarm duration.
  • Added time formatting in minutes and seconds.
  • Added Play and Stop functionality for the alarm.
  • Added visual feedback when the countdown reaches zero.

@shirinpanahian shirinpanahian added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 23, 2026
Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
if (timeInSecond <= 0) {
clearInterval(timer);
playAlarm();
document.body.style.background = "lightRed";

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 the timer expires, what does the browser do with lightRed as a CSS color value?

To "like" or "dislike" this comment, please follow this link

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’ve changed lightRed to the valid CSS colour "red"

@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 23, 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.

@shirinpanahian shirinpanahian 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 Nov 23, 2026

@iscmiguelsamaniego iscmiguelsamaniego 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.

Thank you so much for bringing all of this together! Your countdown logic, helper breakdown, and clean markup show real care and momentum.

Just one gentle thought to explore: how do the pieces connect end-to-end when a user sets, triggers, and resets an alarm? You're doing awesome—keep it up!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you so much for sharing this! Extracting formatTime and clearing previous intervals is super clean and thoughtful.

Just a gentle question: how might stopAlarm vs. pauseAlarm affect what happens when the user stops the alarm, and what happens with alarmTime.innerText right after the if/else block? You're doing great—keep it up!

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.

Thank you for pointing that out! 😊

stopAlarm() does more than pauseAlarm(). While pauseAlarm() only pauses the audio, stopAlarm() also clears the countdown interval, resets the audio to the beginning, changes the background color, and resets the displayed time to 00:00.

Regarding alarmTime.innerText, I realized that placing it after the if/else block means it runs regardless of which condition is true. Therefore, I removed the else section and the duplicate innerText statement. Now the time is updated only once per second, and when it reaches zero, it displays 00:00 instead of a negative value.

Thank you for helping me improve my code!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thank you so much for sharing the HTML! Having a descriptive title like "Alarm clock app" and keeping the IDs and buttons clean is really nice.

Just a gentle question: how might adding a <div> wrapper around the buttons affect layout or styling rules if any expect direct children? You're doing great—keep it up!

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.

Thank you for the feedback! 😊 I think adding a div around the buttons could make it easier to style them together and control their spacing. But I should also check my CSS because some selectors might expect the buttons to be direct children of the centre div. If I add a wrapper, those styles might not work the same way. Thanks for pointing that out!

@Stephanieewelu

Stephanieewelu commented Nov 27, 2026 •

Copy link
Copy Markdown

Great work on this. The core countdown, input validation, and page title updates all meet the task requirements.
Existing intervals are properly cleared before starting a new alarm, and the display reliably reaches 00:00 before audio playback begins.
Your updated stop handler also correctly clears the active timer and pauses the alarm sound.
As an optional improvement, you might consider having stopAlarm() restore the original background styling and reset the display text so the UI doesn't remain stuck in the expired red state.
Everything works as expected, so this is ready to merge whether or not you decide to include that extra polish.

@shirinpanahian

Copy link
Copy Markdown
Author

Thank you for the feedback Stephanieewelu! I've implemented the suggested improvements in stopAlarm() to restore the original background styling and reset the display text when the alarm is stopped.

@Poonam-raj

Copy link
Copy Markdown

@Stephanieewelu @iscmiguelsamaniego - who is owning this code review? I can see both of you have added your feedback - we tend to say one person should stick to a review so it's more straightforward for the trainee and the reviewer. When you first start reviewing a PR, you can indicate you are taking this PR for review by adding the "Review in Progress" label.

Please see our labelling flow for code review - in this PR no labels were added during or after review. Please make sure you add these so that our Portal platform and trainees can see when a review has been done / a PR is complete

Can you decide between you who's owning this, add relevant label, and ask me any questions you might have :D

@Stephanieewelu

Copy link
Copy Markdown

Thank you. I would leave it for the first reviewer to continue.

@shirinpanahian

Copy link
Copy Markdown
Author

@iscmiguelsamaniego Could you please take a look at my PR when you get a chance? Thanks!

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

image

Test case: Set the timer to 1 second and wait for the countdown to complete. The background correctly changes to red when the alarm is triggered, which is great!

However, when you click the Set Alarm button again to start a new countdown, the background should reset to its original white colour. Currently, it remains red.

Could you please check this behaviour and ensure the background resets when a new alarm is started?

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.

Thank you for the feedback @ravinder25886 . I add code for reset the background to white and pause the alarm in Set Alarm

@ravinder25886 ravinder25886 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 4, 2026
@shirinpanahian shirinpanahian 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 Dec 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants