London | May-2026-itp | Vitalii Kmit | Sprint 3 | Alarm clock - #1366
London | May-2026-itp | Vitalii Kmit | Sprint 3 | Alarm clock #1366Vitalii-code wants to merge 10 commits into
Conversation
| @@ -1,4 +1,73 @@ | |||
| function setAlarm() {} | |||
| const oneSecondInMilliseconds = 1000; | |||
There was a problem hiding this comment.
These variables are declared but don't appear to be used anywhere. Are they still needed, or can they be removed to keep the code cleaner?
| stopAlarm(); | ||
|
|
||
| // set up time | ||
| timeLeft = document.getElementById("alarmSet").value; |
There was a problem hiding this comment.
What would happen if I set the alarm for -10 seconds?
|
|
||
| // give a time in seconds | ||
| function formatTime(seconds) { | ||
| minutes = Math.floor(seconds / 60); |
There was a problem hiding this comment.
is minutes supposed to be a global variable?
| minutes = Math.floor(seconds / 60); | ||
| seconds = seconds % 60; | ||
|
|
||
| const seconds_padded = String(seconds).padStart(2, "0"); |
There was a problem hiding this comment.
Does the variable naming convention match style guide?
| // validate result | ||
| const result = parseInt(timeLeft); | ||
| console.log(result); | ||
| if (isNaN(result) || result < 0) { |
There was a problem hiding this comment.
What would happen if I set the alarm to 0 or 2.5 seconds?
| // validate result | ||
| const result = parseInt(timeLeft); | ||
| console.log(result); | ||
| if (isNaN(result) || result < 0 || !Number.isInteger(result)) { |
There was a problem hiding this comment.
The integer validation doesn't seem to be working as expected. What value or type is being passed to Number.isInteger()?
result stores the validated input, but is it being used anywhere after the validation?
hey-hammad
left a comment
There was a problem hiding this comment.
A couple of input-related edge cases need attention. Additionally, users may choose to stop the alarm before the timer expires, so please ensure that scenario is handled correctly as well. Thanks.
|
|
||
| let timeLeft; | ||
| let intervalID; | ||
| let timeoutID; |
There was a problem hiding this comment.
Is this variable being used anywhere? If not, can it be removed?
|
|
||
| // validate result | ||
| const result = Number(timeLeft); | ||
| if (!Number.isInteger(result) || result < 0) { |
There was a problem hiding this comment.
What would happen If I set the alarm for more unexpected values, such an empty input or 0?
There was a problem hiding this comment.
It doesn't start if it's a string, and I fixed the check for zero
Learners, PR Template
Self checklist
Changelist
Worked on the alarm clock