Skip to content

London | 26-ITP-Jan | Alex Okorefe | Sprint 3 | Alarm clock#1179

Open
Alex-Os-Dev-Lab wants to merge 4 commits intoCodeYourFuture:mainfrom
Alex-Os-Dev-Lab:alarm-clock
Open

London | 26-ITP-Jan | Alex Okorefe | Sprint 3 | Alarm clock#1179
Alex-Os-Dev-Lab wants to merge 4 commits intoCodeYourFuture:mainfrom
Alex-Os-Dev-Lab:alarm-clock

Conversation

@Alex-Os-Dev-Lab
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

Completed all task related to Alarm Clock directory

Questions

No questions for now

@Alex-Os-Dev-Lab Alex-Os-Dev-Lab added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Apr 5, 2026
@magarpratik magarpratik 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 Apr 8, 2026
Copy link
Copy Markdown

@magarpratik magarpratik left a comment

Choose a reason for hiding this comment

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

The code is really good! 👍

I found the naming of variables and functions clear and descriptive. Also, the code is organised well making it easy to read and understand.

I've just left a couple of minor comments for you to take a look at.

@@ -1,4 +1,48 @@
function setAlarm() {}
timerInterval = null;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

To align with best practices, could we use a keyword here when initialising the variable?

Comment on lines +2 to +31
function setAlarm() {
// 1. Get the input from the user
const inputField = document.getElementById("alarmSet");
let timeRemaining = parseInt(inputField.value);

// 2. Validate: If no number or 0 is entered, do nothing
if (isNaN(timeRemaining) || timeRemaining <= 0) {
return;
}

// 3. Clear any existing timer; prevent multiple alarms running at once
clearInterval(timerInterval);

// 4. Update the display immediately
updateTimeDisplay(timeRemaining);

// 5. Start the countdown
timerInterval = setInterval(() => {
timeRemaining -= 1;

updateTimeDisplay(timeRemaining);

// 6. Check if timer hit zero
if (timeRemaining <= 0) {
clearInterval(timerInterval);
playAlarm();
document.body.style.backgroundColor = "red";
}
}, 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.

Could you also reset the background colour when "Set Alarm" is clicked again after the timer is up? Right now it stays red, and resetting it would make the UI clearer for the next countdown.

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

Labels

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