London | 26-ITP-May | Dipa Sarker | Sprint 3 | Alarm Clock App - #1294
London | 26-ITP-May | Dipa Sarker | Sprint 3 | Alarm Clock App#1294Dipa-Sarker wants to merge 4 commits into
Conversation
LonMcGregor
left a comment
There was a problem hiding this comment.
Good start on this task, there is still some work to do however
| .padStart(2, "0"); | ||
| const showTimeSeconds = (remainingTime % 60).toString().padStart(2, "0"); | ||
| timeRemainingElement.innerText = showTimeMinutes + ":" + showTimeSeconds; | ||
| if (remainingTime === 0) { |
There was a problem hiding this comment.
Do you properly finish the timer countdown after it hits zero?
There was a problem hiding this comment.
Sorry, I am unclear about your question. But I think I finished the countdown after hitting zero at here:
function countDown() {
if (remainingTime <= 0) {
clearInterval(intervalID);
triggerAlarm();
return;
}
Which means:
- Timer reaches 00:00
- Interval stops
- No negative counting
- Alarm starts
- returns from the code so no extra code runs afterward.
There was a problem hiding this comment.
I see, I was confused that you have a triggerAlarm in the setAlarm function. if you also have it in the countDown function, is it necessary to have it in the setAlarm function also?
There was a problem hiding this comment.
if (remainingTime <= 0) {
clearInterval(intervalID);
triggerAlarm();
return;
}
this condition serves different purpose inside setAlarm() function. I commented out every possible confusing condition in my code. Please let me know if there any confusion again.
|
|
||
| let remainingTime; | ||
| let intervalID; | ||
| function triggerAlarm() { |
There was a problem hiding this comment.
A bit more spacing between functions / improved formatting would help readability.
There was a problem hiding this comment.
Actually, I used prettier tool according to the style guide for formatting. Should I provide extra spaces in between functions?
There was a problem hiding this comment.
A clear line between functions is a good idea
There was a problem hiding this comment.
I placed one line inside functions.
| window.onload = setup; | ||
|
|
||
| const timeRemainingElement = document.querySelector("#timeRemaining"); | ||
| const alarmSetElement = document.querySelector("#alarmSet"); |
There was a problem hiding this comment.
If you know you are using IDs, can you think of something better tha n querySelector?
There was a problem hiding this comment.
Replaced every querySelector() by getElementID().
LonMcGregor
left a comment
There was a problem hiding this comment.
Good improvement with the input validation, almost complete with the other tasks
| .padStart(2, "0"); | ||
| const showTimeSeconds = (remainingTime % 60).toString().padStart(2, "0"); | ||
| timeRemainingElement.innerText = showTimeMinutes + ":" + showTimeSeconds; | ||
| if (remainingTime === 0) { |
There was a problem hiding this comment.
I see, I was confused that you have a triggerAlarm in the setAlarm function. if you also have it in the countDown function, is it necessary to have it in the setAlarm function also?
|
|
||
| let remainingTime; | ||
| let intervalID; | ||
| function triggerAlarm() { |
There was a problem hiding this comment.
A clear line between functions is a good idea
Learners, PR Template
Self checklist
Changelist
Implemented the alarm clock functionality with countdown and alarm controls.
** Changes made**
I also tested the functions to works the app properly.