Sheffield | 26-ITP-Jan | Mahmoud Shaabo | Sprint 3 | Alarm Clock App#1155
Sheffield | 26-ITP-Jan | Mahmoud Shaabo | Sprint 3 | Alarm Clock App#1155mahmoudshaabo1984 wants to merge 1 commit intoCodeYourFuture:mainfrom
Conversation
|
Hi @cifarquhar, Here is my Pull Request for the Alarm Clock App. I successfully implemented the timer logic using Looking forward to your feedback! |
cjyuan
left a comment
There was a problem hiding this comment.
-
Can you make the "Stop" button to also stop the count down? You can add another "click" event listener to the button to avoid modifying the original code.
-
When input is 1, the alarm is played one second later -- an expected behavior.
However, when input is 0, the alarm is also played one second later (instead of being played immediately). Can you make the app's behaviour more consistent?
| const mins = String(Math.floor(totalSeconds / 60)).padStart(2, "0"); | ||
| const secs = String(totalSeconds % 60).padStart(2, "0"); | ||
| document.getElementById("timeRemaining").innerText = | ||
| "Time Remaining: " + mins + ":" + secs; |
There was a problem hiding this comment.
Instead of keeping several copies of the code for displaying time (lines 18-21, lines 44-47, lines 32-33),
it is better to define a function to update the time display and call the function to update the time display.
Advantages:
- Keep the logic for updating time display in one place
- Less code
| document.body.style.backgroundColor = ""; | ||
|
|
||
| // Read the input value and convert it to a plain integer (total seconds) | ||
| let totalSeconds = parseInt(document.getElementById("alarmSet").value); |
There was a problem hiding this comment.
Some integer values or unusual input can still make your app behave abnormally. Can you figure out a way to prevent that from happening?
| // Clear any previously running countdown | ||
| clearInterval(interval); | ||
|
|
||
| // Reset background to default | ||
| document.body.style.backgroundColor = ""; | ||
|
|
There was a problem hiding this comment.
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. In addition to resetting the countdown and the background color, what else should also be reset? (Hint: a user may not click the "Stop" button first before starting a new count down.)
Hello Reviewers / CodeYourFuture Team,
I have completed the Alarm Clock App project for Sprint 3.
Acceptance Criteria Met:
index.htmlto "Alarm clock app".setAlarm()inalarmclock.jsto read the input and display the time inmm:ssformat.setInterval()to decrement the timer every 1 second.00:00, the interval is cleared, the background changes to red, and the alarm audio plays.Thank you for your review!