Cape Town | 2026-ITP-Jan | Isaac Abodunrin | Sprint 3 | Grouping data: Alarm Clock#1182
Cape Town | 2026-ITP-Jan | Isaac Abodunrin | Sprint 3 | Grouping data: Alarm Clock#1182bytesandroses wants to merge 14 commits intoCodeYourFuture:mainfrom
Conversation
|
|
||
| function setAlarm() { | ||
| const setTime = document.getElementById("alarmSet").value; | ||
| timeRemaining = parseInt(setTime, 10); |
There was a problem hiding this comment.
Using user input without proper validation and sanitisation can be dangeours.
Currently, some unusual input values can make your app behave abnormally. Can you add code to sanitise them?
| if (timerInterval) { | ||
| clearInterval(timerInterval); | ||
| } |
There was a problem hiding this comment.
The countdown interval is not the only state to be reset.
Hint: a user may not click the "Stop" button first before starting a new count down.
You can also consider introducing a dedicated reset function to return the app to a clean initial state to help ensure consistency.
| function decreaseAlarmTime() { | ||
| if (timeRemaining <= 0) { | ||
| clearInterval(timerInterval); | ||
| timerInterval = null; | ||
| timeRemaining = 0; | ||
| playAlarm(); | ||
| return; | ||
| } | ||
|
|
||
| timeRemaining--; | ||
| displayAlarm(timeRemaining); | ||
| } |
There was a problem hiding this comment.
When the countdown reaches 00:00, there is a one second delay before the alarm sound is played. Is this by design?
At line 25, when timeRemaining changes from 1 to 0, the app only changes the display to 00:00. It's only in the next interval, the code on lines 17-22 is executed.
Self checklist
Changelist
Implemented alarm clock functionality and countdown timer logic to