Birmingham | ITP-Jan-26 | Ayodeji Ayorinde | Sprint 3| Alarm Clock#1128
Open
Ayogit1 wants to merge 1 commit intoCodeYourFuture:mainfrom
Open
Birmingham | ITP-Jan-26 | Ayodeji Ayorinde | Sprint 3| Alarm Clock#1128Ayogit1 wants to merge 1 commit intoCodeYourFuture:mainfrom
Ayogit1 wants to merge 1 commit intoCodeYourFuture:mainfrom
Conversation
magarpratik
suggested changes
Apr 3, 2026
magarpratik
left a comment
There was a problem hiding this comment.
Really great work! 🙌
The code is very easy to read and understand. I found the variable names quite descriptive and the code well structured.
I've just added a few comments highlighting minor points. Overall the PR looks very good! 👍
| @@ -1,4 +1,49 @@ | |||
| function setAlarm() {} | |||
| //function setAlarm() {} | |||
Comment on lines
+34
to
+46
| /** | ||
| * Helper function to format the time as 00:00 | ||
| */ | ||
| function updateDisplay(totalSeconds, displayElement) { | ||
| const minutes = Math.floor(totalSeconds / 60); | ||
| const seconds = totalSeconds % 60; | ||
|
|
||
| // Converts numbers to strings and pads with a leading zero if needed | ||
| const formattedMinutes = minutes.toString().padStart(2, "0"); | ||
| const formattedSeconds = seconds.toString().padStart(2, "0"); | ||
|
|
||
| displayElement.innerText = `Time Remaining: ${formattedMinutes}:${formattedSeconds}`; | ||
| } |
Comment on lines
+10
to
+11
| // Safety check: Ensure input is a number and greater than 0 | ||
| if (!alarmInput || alarmInput <= 0) return; |
There was a problem hiding this comment.
This check technically allows non-numeric string inputs (e.g. "hello") to pass through. It’s probably fine since the input field appears restricted to numbers, but worth noting.
Comment on lines
+5
to
+32
| function setAlarm() { | ||
| // 1. Get the input value and the display element | ||
| const alarmInput = document.getElementById("alarmSet").value; | ||
| const timeRemainingDisplay = document.getElementById("timeRemaining"); | ||
|
|
||
| // Safety check: Ensure input is a number and greater than 0 | ||
| if (!alarmInput || alarmInput <= 0) return; | ||
|
|
||
| let timeRemaining = parseInt(alarmInput); | ||
|
|
||
| // 2. Clear any existing timers to prevent "speeding up" if clicked multiple times | ||
| clearInterval(countdownInterval); | ||
|
|
||
| // 3. Initial update so the user sees the time immediately | ||
| updateDisplay(timeRemaining, timeRemainingDisplay); | ||
|
|
||
| // 4. Start the countdown logic | ||
| countdownInterval = setInterval(() => { | ||
| timeRemaining -= 1; | ||
| updateDisplay(timeRemaining, timeRemainingDisplay); | ||
|
|
||
| // 5. Trigger the alarm and stop the counter when 0 is reached | ||
| if (timeRemaining <= 0) { | ||
| clearInterval(countdownInterval); | ||
| playAlarm(); | ||
| } | ||
| }, 1000); | ||
| } |
There was a problem hiding this comment.
It seems one of the A/C is missing:
Given the alarm is set with a time of 00:10
When the timer reaches 00:00
Then the background colour should change
And the alarm sound should play
Could you look into it?
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 alarm clock task