Glasgow | Jan-26 | Elisabeth Matulian | Sprint 3 | Alarm clock app#1020
Glasgow | Jan-26 | Elisabeth Matulian | Sprint 3 | Alarm clock app#1020Elisabeth-Matulian wants to merge 4 commits intoCodeYourFuture:mainfrom
Conversation
| function pauseAlarm() { | ||
| audio.pause(); | ||
| //I know it's said to not edit this code, I wonder if it's ok to add this line below in order to pause the time before the time runs out. | ||
| clearInterval(intervalId); | ||
| } |
There was a problem hiding this comment.
Excellent catch, and the approach is correct, as a bonus task, though, how can we make this change and add the clearInterval call, without editing anything below the // DO NOT EDIT BELOW HERE line?
There was a problem hiding this comment.
Could you give me a hint?
There was a problem hiding this comment.
Sure thing, what if I told you that you can have multiple event listeners for the same element?
There was a problem hiding this comment.
I still couldn't figure out how to implement it 😵💫
There was a problem hiding this comment.
You have actually done it, but the code is commented out on lines 43-45. You can indeed register multiple event listeners to the same element as you did; they won't override each other. For what is worth, adding them in the pause alarm did make sense too, but I hope it was an interesting extra step. Let's comment it back it and I will approve :)
There was a problem hiding this comment.
Oh, so that’s how it works)))
I didn’t think it would work, I just left it as a comment so you could see the way I think and point me in the right direction. That’s surely something I’ll remember))
|
Finally, let's try to add a few more details to the Changelist. The purpose of the changelist is to mention individual updates/additions/changes made for this PR, not so much to add a headline (like the title) of the changes. |
| function pauseAlarm() { | ||
| audio.pause(); | ||
| //I know it's said to not edit this code, I wonder if it's ok to add this line below in order to pause the time before the time runs out. | ||
| clearInterval(intervalId); | ||
| } |
There was a problem hiding this comment.
Sure thing, what if I told you that you can have multiple event listeners for the same element?
|
Awesome work |
Learners, PR Template
Self checklist
Changelist
Updated the <title> tag in index.html
Implemented the setAlarm() function
Added a countdown timer with the title updated every second
Added clearInterval to pauseAlarm() to stop the timer
Questions
N/Q