Repository navigation
London | 26-ITP-Sept | Fung Nin Lee | Sprint 3 | Alarm Clock - #1579
leerogerfn wants to merge 5 commits into
Conversation
| const countdownId = setInterval(() => { | ||
| numberForTime -= 1; | ||
| updateDisplay(numberForTime); | ||
|
|
||
| if (numberForTime <= 0) { | ||
| clearInterval(countdownId); | ||
| playAlarm(); | ||
| } | ||
| }, 1000); |
There was a problem hiding this comment.
If Set Alarm is clicked again before this interval finishes, what happens to the countdown created here?
To "like" or "dislike" this comment, please follow this link
There was a problem hiding this comment.
This is one of the important edge cases. Please look into this.
| if (numberForTime <= 0 || Number.isInteger(numberForTime) === false) { | ||
| return (document.getElementById("reminder").textContent = | ||
| "Value of time should be more than '0'."); |
There was a problem hiding this comment.
What message does a user see after entering a positive fractional value, and does it explain why that value was rejected?
To "like" or "dislike" this comment, please follow this link
There was a problem hiding this comment.
What if I input a decimal number like 2.5?
|
The CYF AI review has left comments. It will only review a PR one time. When you have addressed these comments, please request review again and a volunteer will take a look. |
|
Good job! The code is clean and fairly structured. The code runs for the happy path. Please handle the edge case. These are technical discussions, so feel free to ask anything. |
| } | ||
|
|
||
| document.getElementById("reminder").textContent = ""; | ||
| function updateDisplay(totalSeconds) { |
There was a problem hiding this comment.
Here's an unused variable in the method parameters. Can we try using the variable in the params and modify the code logic?
Hint: It is inside the setAlarm function. Try to move it out of the function.
| if (numberForTime <= 0 || Number.isInteger(numberForTime) === false) { | ||
| return (document.getElementById("reminder").textContent = | ||
| "Value of time should be more than '0'."); |
There was a problem hiding this comment.
What if I input a decimal number like 2.5?
| let numberForTime = Number(timeSubmitted); | ||
|
|
||
| if (numberForTime <= 0 || Number.isInteger(numberForTime) === false) { | ||
| return (document.getElementById("reminder").textContent = |
There was a problem hiding this comment.
We are going to use document.getElementById("remainder") in line 17. Can we store this value and refer to it later?
There was a problem hiding this comment.
I don't understand what it means.
There was a problem hiding this comment.
Can we use variables to store the element?
There was a problem hiding this comment.
Look up each element once. document.getElementById("reminder") appears three times. Saving it in a const at the top of setAlarm makes the code shorter and easier to change later.
| <h1 id="timeRemaining">Time Remaining: 00:00</h1> | ||
| <label for="alarmSet">Set time to:</label> | ||
| <input id="alarmSet" type="number" /> | ||
| <p id="reminder" style="color: red"></p> |
There was a problem hiding this comment.
We were trying to do something here, I guess. What was the chain of thought?
There was a problem hiding this comment.
I don't understand what it means
There was a problem hiding this comment.
I'm asking about the reason for the change.
There was a problem hiding this comment.
This line is for showing the reminder of non-integer value submission and re-pressing "set alarm" during counting down.
| function setAlarm() {} | ||
| function setAlarm() { | ||
| const timeSubmitted = document.getElementById("alarmSet").value; | ||
| let numberForTime = Number(timeSubmitted); |
There was a problem hiding this comment.
The naming convention could have been better. You are converting the string to int.
|
@leerogerfn, you have settled the important comments. Consider this a challenge to improve your code and a chance to be better. Please let me know if you have any questions. |
eliza-an
left a comment
There was a problem hiding this comment.
There are still some comments unresolved on this mr. please have a look at them and chaneg the labvle when you're ready :)
Hi, could you advise which part need to improve in the function? Thank you. |
|
@leerogerfn Here's the comment that is pending - #1579 (comment). Please resolve. I'm guessing you were having trouble understanding what it means. So, the hint is more clear now. You should be able to take it from here. Thanks. |
Learners, PR Template
Self checklist
Task code
CYF-1098
Changelist
Implemented the function of alarm clock.