Cape Town | 2026-ITP-Jan | Pretty Taruvinga | Sprint 3 | Alarm clock#1193
Cape Town | 2026-ITP-Jan | Pretty Taruvinga | Sprint 3 | Alarm clock#1193Pretty548 wants to merge 10 commits intoCodeYourFuture:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
4 similar comments
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.
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.
- You missed updating
index.htmlaccording to an instruction inreadme.md.
| @@ -1,4 +1,38 @@ | |||
| function setAlarm() {} | |||
| let timeLeft = 0; | |||
There was a problem hiding this comment.
Could declare timeLeft inside setAlarm() (since it is only used within that function).
There was a problem hiding this comment.
Thanks for the suggestion! I’ve moved timeLeft inside setAlarm to limit its scope and keep the global space cleaner.
There was a problem hiding this comment.
It's still declared in the outermost scope.
There was a problem hiding this comment.
Good catch — I had left the global timeLeft in by mistake. I’ve removed it and kept it scoped inside setAlarm() 👍
| if (timer) { | ||
| clearInterval(timer); | ||
| } |
There was a problem hiding this comment.
What elsse should also be reset before a new countdown begin?
Hint: a user may not click the "Stop" button first before starting a new count down.
There was a problem hiding this comment.
Good point I’ve reset the timer reference to null after clearing it to ensure a clean state before starting a new countdown.
There was a problem hiding this comment.
-
Setting timer to
nullis unnecessary in JS but it is a good practice. -
What does the "Stop" button do? What would happen when a countdown reaches zero, and the user immediately set another countdown?
There was a problem hiding this comment.
The Stop button clears the timer and stops the alarm. If a countdown reaches zero and the user immediately starts another one, the alarm may still be playing. So we should also reset/stop the alarm when starting a new countdown to keep the behavior consistent.
…g, and timer logic"
cjyuan
left a comment
There was a problem hiding this comment.
Changes look good. Well done.
Learners, PR Template
Self checklist
Changelist
Fixed my code and removed whats not supposed to be there.