Skip to content

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

Open
Dagim-Daniel wants to merge 2 commits into
CodeYourFuture:mainfrom
Dagim-Daniel:Sprint3/alarmclock
Open

London | 26-ITP-May | Dagim Daniel | Sprint 3 | Alarm clock#1331
Dagim-Daniel wants to merge 2 commits 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
Comment thread Sprint-3/alarmclock/alarmclock.js
Comment thread Sprint-3/alarmclock/alarmclock.js
Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
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 Aug 3, 2026
@Dagim-Daniel Dagim-Daniel added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 3, 2026

@cjyuan cjyuan left a comment

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.

Most of the changes you made are good.

Sorry that I just noticed some more stuffs you could also improve.

setButton.disabled = false;
document.body.style.background = "";
}
let countdownInterval;

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.

Between this variable and the variable declared on line 6, one of them is not used and one of the them seems to be misspelled.

Comment on lines +26 to +31
let timeleft = Number(totalSeconds.value);

if (timeleft <= 0 || isNaN(timeleft)) {
alert("please enter a number greater than zero (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.

What type of number should the input be?

display.textContent = formatTime(timeleft);

const warningTime = 10; // seconds
clearInterval(conuntdownInterval);

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.

Is clearing countdownInterval necessary before starting a new countdown?

If clearing it is necessary, then it is likely that we should also call reset() here.

Comment on lines +58 to +62
stopButton.addEventListener("click", () => {
clearInterval(conuntdownInterval);
reset();
pauseAlarm();
});

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.

addEventListener() can add multiple event listeners (callbacks) to a DOM object.

Normally if we could modify all the code, we could just update the original callback (lines 73-75). Since we are adding another onclick callback to stopButton, we should avoid repeating the task performed by the original callback.

Comment on lines +34 to +40
display.textContent = formatTime(timeleft);

const warningTime = 10; // seconds
clearInterval(conuntdownInterval);

conuntdownInterval = setInterval(() => {
timeleft--;

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.

New countdown implementation is good. You could consider moving the statement that displays the initial time on line 34 to just before line 39 so that the code in the function reads more like:

// Process input

// Reset/initialize states

// Start countdown

@cjyuan cjyuan removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label 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