London | 26-ITP-Jan | Kris Oldrini | Sprint 3 | Alarm Clock App#1208
London | 26-ITP-Jan | Kris Oldrini | Sprint 3 | Alarm Clock App#1208XiaoQuark wants to merge 7 commits intoCodeYourFuture:mainfrom
Conversation
…ent based on user input
…ge the time in the UI
…y storing interval ID in state
A-O-Emmanuel
left a comment
There was a problem hiding this comment.
This is a good attempt, but i noticed the following things:
- When I click the
set alarmbutton the timer starts counting backwards. - The inpput field accepts negative numbers.
…er from going below 0
|
Thank you for the feedback. I implemented input validation so so the timer only accepts positive integers, and cannot count below |
|
Hello @A-O-Emmanuel |
| state.remainingTime = +timeInput.value; | ||
| if (state.remainingTime <= 0 || !Number.isInteger(state.remainingTime)) { | ||
| state.remainingTime = 0; | ||
| displayedTime.textContent = `Time Remaining: 00:00`; |
There was a problem hiding this comment.
I've noticed you have three different places where you set this content to "Time remaining: XX:YY" - imagine you wanted to change this in some way (e.g. "Time Left: XX:YY" or similar) - you'd need to change all three. Can you think how to avoid that?
There was a problem hiding this comment.
Thank you very much Daniel.
I will have a look at this as soon as I'm done with all my submissions.
illicitonion
left a comment
There was a problem hiding this comment.
I'm going to mark this as complete, but I left one bonus thing to consider :)
Learners, PR Template
Self checklist
Changelist
HTML
titleto "Alarm clock app"Script
setAlarm()function to display the inputted time in the UIformatTime()to convert seconds intoMM:SSformatstate, for easier access across functionstimer()function, usingsetInterval(), that decreases the time every 1000 millisecondplayAlarm()when the countdown reaches00:0000:00when the alarm triggersTest
Extra Tasks