London | 26-ITP-May | Vito Moratti | Sprint 3 | Alarm-clock - #1384
London | 26-ITP-May | Vito Moratti | Sprint 3 | Alarm-clock#1384vmoratti wants to merge 9 commits into
Conversation
hey-hammad
left a comment
There was a problem hiding this comment.
- If the user clicks "Stop Alarm" before the timer reaches 00:00, what happens to the countdown? Will the alarm still ring when the timer finishes?
- Could formatTime() do its job by returning the formatted time instead of relying on and updating global variables?
Refactor formatTime function to accept remainingSeconds as a parameter and return formatted time string. Update alarm display logic to use the new formatTime function.
|
I have now made the recommended adjustments. |
hey-hammad
left a comment
There was a problem hiding this comment.
Nice effort fixing the application state, few changes required regarding code quality.
| //5. starts timer | ||
| clearInterval(timer); | ||
| remainingSeconds = Number(document.getElementById("alarmSet").value); | ||
| if (remainingSeconds === 0) { |
There was a problem hiding this comment.
Is there a reason we're handling 0 and negative values separately here? Since both cases seem to represent invalid input, would it make sense to use a single validation check and provide user feedback (e.g., an alert/message) instead?
| } else if (remainingSeconds < 0) { | ||
| return clearInterval(timer); | ||
| } | ||
| formatTime(); |
There was a problem hiding this comment.
What's the purpose of the standalone formatTime() call here? It looks like the return value isn't used, and the formatted value is already generated in the next line.
| remainingSeconds = remainingSeconds - 1; | ||
| alarmDisplay.textContent = `Time Remaining: ${formatTime(remainingSeconds)}`; | ||
| } | ||
| function stopTimer() { |
There was a problem hiding this comment.
Is stopTimer() still needed? I don't see it being called anywhere.
There was a problem hiding this comment.
the stopTime() function is being used by HTML file on line 16 by "Stop alarm" button.
| alarmDisplay.textContent = `Time Remaining: ${formatTime(remainingSeconds)}`; | ||
| timer = setInterval(updateDisplay, 1000); | ||
| } | ||
| function changeBackground() { |
There was a problem hiding this comment.
Is it possible to make this function act like a toggle? Currently it turns red and doesn't return to the original state when setting a new alarm.
There was a problem hiding this comment.
I have made the adjustments to accommodate that
Learners, PR Template
Self checklist
Changelist
Completed implementation of the alarm clock