London | 26-ITP-May | Gideon Defar | Sprint 3 | Alarm Clock App - #1423
London | 26-ITP-May | Gideon Defar | Sprint 3 | Alarm Clock App#1423gideondefar wants to merge 5 commits into
Conversation
|
|
||
| function setAlarm() { | ||
|
|
||
| if (timer) clearInterval(timer); |
There was a problem hiding this comment.
In the browser, start a 10-second countdown, then clear the input box and click Set Alarm again. What happens to the countdown, and is that what a user would expect? Have a look at the order of this line and line 23.
There was a problem hiding this comment.
Now it keeps countdown to 0.
| audio.currentTime = 0; | ||
|
|
||
| let time = Number(document.getElementById("alarmSet").value); | ||
| if (isNaN(time) || !Number.isInteger(time) || time <= 0) return; |
There was a problem hiding this comment.
Run Number.isInteger(NaN) into your browser console and what comes back? Is the isNaN(time) check earning its place here?
There was a problem hiding this comment.
You are right, It's kind of redundant, So I removed it. !Number.isInteger(time) already checks the condition.
|
|
||
| function updateDisplay(time) { | ||
|
|
||
| let heading = document.getElementById("timeRemaining"); |
There was a problem hiding this comment.
None of these three are ever reassigned. What's your rule for picking between let and const?
There was a problem hiding this comment.
Thanks for the feedback! ooh I see you are right. I use let basically to reassign the variable later but const is for fixed or constant variables.
Self checklist
Changelist
Implemented the Alarm Clock assignment.
Updated the page title to "Alarm clock app"
Added the alarm countdown functionality
Added minute and second formatting
Added a countdown that updates every second
Added alarm playback when the countdown reaches zero
Kept the existing Stop Alarm functionality