Skip to content

London | 26-ITP-Sept | Fung Nin Lee | Sprint 3 | Alarm Clock - #1579

Open
leerogerfn wants to merge 5 commits into
CodeYourFuture:mainfrom
leerogerfn:sprint-3/alarm-clock
Open

leerogerfn wants to merge 5 commits into
CodeYourFuture:mainfrom
leerogerfn:sprint-3/alarm-clock

Conversation

@leerogerfn

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 the function of alarm clock.

@leerogerfn leerogerfn added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Data-Groups The name of the module. labels Nov 23, 2026
Comment on lines +23 to +31
const countdownId = setInterval(() => {
numberForTime -= 1;
updateDisplay(numberForTime);

if (numberForTime <= 0) {
clearInterval(countdownId);
playAlarm();
}
}, 1000);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If Set Alarm is clicked again before this interval finishes, what happens to the countdown created here?

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is one of the important edge cases. Please look into this.

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
Comment on lines +5 to +7
if (numberForTime <= 0 || Number.isInteger(numberForTime) === false) {
return (document.getElementById("reminder").textContent =
"Value of time should be more than '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.

What message does a user see after entering a positive fractional value, and does it explain why that value was rejected?

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

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 if I input a decimal number like 2.5?

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

@leerogerfn leerogerfn 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
@shashwatksingh shashwatksingh 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 Nov 24, 2026
@shashwatksingh

Copy link
Copy Markdown

Good job! The code is clean and fairly structured. The code runs for the happy path. Please handle the edge case. These are technical discussions, so feel free to ask anything.

@shashwatksingh shashwatksingh 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 Nov 24, 2026
@leerogerfn leerogerfn 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 26, 2026
Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
}

document.getElementById("reminder").textContent = "";
function updateDisplay(totalSeconds) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Here's an unused variable in the method parameters. Can we try using the variable in the params and modify the code logic?

Hint: It is inside the setAlarm function. Try to move it out of the function.

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
Comment on lines +5 to +7
if (numberForTime <= 0 || Number.isInteger(numberForTime) === false) {
return (document.getElementById("reminder").textContent =
"Value of time should be more than '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.

What if I input a decimal number like 2.5?

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
let numberForTime = Number(timeSubmitted);

if (numberForTime <= 0 || Number.isInteger(numberForTime) === false) {
return (document.getElementById("reminder").textContent =

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We are going to use document.getElementById("remainder") in line 17. Can we store this value and refer to it later?

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.

I don't understand what it means.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Can we use variables to store the element?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Look up each element once. document.getElementById("reminder") appears three times. Saving it in a const at the top of setAlarm makes the code shorter and easier to change later.

<h1 id="timeRemaining">Time Remaining: 00:00</h1>
<label for="alarmSet">Set time to:</label>
<input id="alarmSet" type="number" />
<p id="reminder" style="color: red"></p>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We were trying to do something here, I guess. What was the chain of thought?

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.

I don't understand what it means

@shashwatksingh shashwatksingh Nov 27, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I'm asking about the reason for the change.

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.

This line is for showing the reminder of non-integer value submission and re-pressing "set alarm" during counting down.

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
function setAlarm() {}
function setAlarm() {
const timeSubmitted = document.getElementById("alarmSet").value;
let numberForTime = Number(timeSubmitted);

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 naming convention could have been better. You are converting the string to int.

@shashwatksingh shashwatksingh 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 27, 2026
@shashwatksingh shashwatksingh added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Nov 27, 2026
@shashwatksingh

Copy link
Copy Markdown

@leerogerfn, you have settled the important comments.

Consider this a challenge to improve your code and a chance to be better. Please let me know if you have any questions.

@leerogerfn leerogerfn 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 27, 2026

@eliza-an eliza-an 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.

There are still some comments unresolved on this mr. please have a look at them and chaneg the labvle when you're ready :)

@eliza-an eliza-an removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 2, 2026
@leerogerfn

Copy link
Copy Markdown
Author

@leerogerfn, you have settled the important comments.

Consider this a challenge to improve your code and a chance to be better. Please let me know if you have any questions.

Hi, could you advise which part need to improve in the function? Thank you.

@shashwatksingh

Copy link
Copy Markdown

@leerogerfn Here's the comment that is pending - #1579 (comment). Please resolve. I'm guessing you were having trouble understanding what it means. So, the hint is more clear now. You should be able to take it from here. Thanks.

@leerogerfn leerogerfn added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 3, 2026
@shashwatksingh shashwatksingh 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 Dec 4, 2026
@shashwatksingh shashwatksingh added Reviewed Volunteer to add when completing a review with trainee action still to take. 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. 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

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Data-Groups The name of the module. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants