London | 26-ITP-May | Chinwe Chukwuma | Sprint 3 | Alarm Clock - #1354
London | 26-ITP-May | Chinwe Chukwuma | Sprint 3 | Alarm Clock#1354ChinweP wants to merge 18 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cjyuan
left a comment
There was a problem hiding this comment.
-
Code works fine if a user only clicks the "Set Alarm" button once.
However, if the user enters a time and then clicks the "Set Alarm" button multiple times, the countdown clock will not display properly. -
Currently when starting a new countdown, the application does not always return to a clean initial state, which can lead to inconsistent behaviour between runs.
Consider introducing a dedicated reset function to return the app to a clean initial state to help ensure consistency.
Hint: a user may not click the "Stop" button first before starting a new count down.
| return `${mm}:${ss}`; | ||
| } | ||
|
|
||
| heading.innerText = `Time Remaining: ${formatTime(remainingSeconds)}`; |
There was a problem hiding this comment.
The time displaying code is used on lines 17, 23, and 25. As such, should the presentation logic changes in the future (e.g., change of wording), you would have to modify the code at three different places.
Why not implement a function to keep the time displaying code in once place?
| function stopFlashingBackground() { | ||
| document.body.classList.remove("flash"); | ||
| } |
There was a problem hiding this comment.
-
This function is never used.
-
Could consider design the function to take a Boolean parameter so that the function can be used to turn the flashing background on/off.
| const input = document.getElementById("alarmSet"); | ||
| const heading = document.getElementById("timeRemaining"); | ||
|
|
||
| let remainingSeconds = Number(input.value); |
There was a problem hiding this comment.
What input should the app reject to prevent the app from behaving abnormally?
… improved flash toggle.
|
Hi @cjyuan, thank you for the helpful feedback. I've applied all the suggested changes and updated the implementation accordingly. |
cjyuan
left a comment
There was a problem hiding this comment.
Changes look good. Just one more change needed.
| function resetAlarm() { | ||
| clearInterval(intervalId); | ||
| intervalId = null; | ||
| updateDisplay(0); | ||
| setFlashingBackground(false); | ||
| } |
There was a problem hiding this comment.
A user may not click the "Stop" button first before starting a new count down. What else should also be reset?
Hint: When the "Stop" button is clicked, what action is performed?
Learners, PR Template
Self checklist
Changelist
Sprint 3/Alarm clock coursework completed following readme instructions.