Skip to content

London | 26-ITP-May | Dagim Daniel | Sprint 3 | Alarm clock - #1331

Open
Dagim-Daniel wants to merge 1 commit into
CodeYourFuture:mainfrom
Dagim-Daniel:Sprint3/alarmclock
Open

London | 26-ITP-May | Dagim Daniel | Sprint 3 | Alarm clock#1331
Dagim-Daniel wants to merge 1 commit into
CodeYourFuture:mainfrom
Dagim-Daniel:Sprint3/alarmclock

Conversation

@Dagim-Daniel

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

tasks under Sprint 3 alarm has been done

@Dagim-Daniel Dagim-Daniel added 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 Jul 28, 2026

// button event handler
setButton.addEventListener("click", () => {
let timeleft = Number(totalSeconds.value);

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.

Some unusual input values can make your app behave abnormally. Can you add code to sanitise them?

Comment on lines +39 to +54
conuntdownInterval = setInterval(() => {
if (timeleft == 0) {
clearInterval(conuntdownInterval);
document.body.style.backgroundColor = "grey";
playAlarm();
}

if (timeleft <= 10) {
display.style.color = "red";
}

if (timeleft >= 0) {
display.textContent = formatTime(timeleft);
timeleft--;
}
}, 1000);

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.

When a user clicks the "Set" button with 1 second as input, the user will only see "00:00" 2 seconds later. Is the extra 1 second delay at the beginning by design?

Comment on lines +46 to +48
if (timeleft <= 10) {
display.style.color = "red";
}

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.

What does this 10 represent? Numbers other than 0 and 1 are generally considered magic numbers, so it is good practice to replace them with named constants.

Comment on lines +28 to +35
setButton.disabled = true;

// time 0

if (timeleft <= 0) {
alert("please enter a number greater than 0!");
return;
}

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.

Would it be better to disable the button only when a countdown is successfully set?

Comment on lines +19 to +23
function clearEverything() {
display.style.color = "black";
setButton.disabled = false;
document.body.style.background = "";
}

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.

What about calling it "reset..."?

Could also consider resetting the display time to "00:00" here.

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

Labels

Module-Data-Groups The name of the module. Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants