London | 26-ITP-Jan | Alex Okorefe | Sprint 3 | Alarm clock#1179
Open
Alex-Os-Dev-Lab wants to merge 4 commits intoCodeYourFuture:mainfrom
Open
London | 26-ITP-Jan | Alex Okorefe | Sprint 3 | Alarm clock#1179Alex-Os-Dev-Lab wants to merge 4 commits intoCodeYourFuture:mainfrom
Alex-Os-Dev-Lab wants to merge 4 commits intoCodeYourFuture:mainfrom
Conversation
magarpratik
reviewed
Apr 8, 2026
magarpratik
left a comment
There was a problem hiding this comment.
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; | |||
There was a problem hiding this comment.
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); | ||
| } |
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Learners, PR Template
Self checklist
Changelist
Completed all task related to Alarm Clock directory
Questions
No questions for now