London | 26-ITP-Jan | Xuanming Hu | Sprint 3 | Alarm Clock App#1115
London | 26-ITP-Jan | Xuanming Hu | Sprint 3 | Alarm Clock App#1115Samual-Hu wants to merge 3 commits intoCodeYourFuture:mainfrom
Conversation
|
|
||
| let timeRemaining = parseInt(inputElement.value, 10) || 0; | ||
|
|
||
| clearInterval(countdownInterval); |
There was a problem hiding this comment.
Nice that the old interval is cleared when the alarm is set again
Sprint-3/alarmclock/alarmclock.js
Outdated
| countdownInterval = setInterval(() => { | ||
| timeRemaining--; | ||
|
|
||
| if (timeRemaining < 0) { |
There was a problem hiding this comment.
When does the alarm start when you are comparing for < 0 ?
There was a problem hiding this comment.
Using '< 0' makes the alarm trigger one second late. I have updated it to '<= 0'. Thanks
|
Hi @Luro91, I have updated the code based on your feedback. |
| clearInterval(countdownInterval); | ||
| playAlarm(); |
There was a problem hiding this comment.
What does the countdown show when the alarm plays?
There was a problem hiding this comment.
Because updateDisplay() was inside the else block, the screen would freeze at 00:01 while the alarm played, never actually showing 00:00.
|
Hi @Luro91 , I have updated the display first before checking the |
Learners, PR Template
Self checklist
Changelist
setAlarmwithsetInterval.padStart.Questions
N/A