London Class No 7 - Nigel Pelvin - Javascript Core 2 - Week 3#27
London Class No 7 - Nigel Pelvin - Javascript Core 2 - Week 3#27nPelvin wants to merge 1 commit intoCodeYourFuture:mainfrom
Conversation
Mandatory exercise functions built with some basic styling. These will be updated and improved during the week.
AhmadJanah
left a comment
There was a problem hiding this comment.
Hi Nigel,
I reviewed your code, and I left some comments.
However, you really did very amazing work. congratulation.
Regards,
| @@ -1,4 +1,31 @@ | |||
| function setAlarm() {} | |||
| function refresh(){ | |||
There was a problem hiding this comment.
Hi Nigel,
Well done. you have accomplished it.
I know you did the requirements, but as an extra challenge. try to input 15 seconds as an example and press (set alarm), after 2 or 3 seconds press it again. Can you solve it??
Regards,
|
|
||
|
|
||
|
|
||
| function autoForward(){ |
There was a problem hiding this comment.
Great work Nigel.
Could you try to call the forward and backward functions in the auto functions instead of repeating the code?
Regards,
| let alarmTime = document.getElementById("alarmSet").value; | ||
| let minutes = Math.floor(alarmTime / 60); | ||
| let seconds = alarmTime % 60; | ||
| document.getElementById("timeRemaining").innerHTML=`Time Remaining: ${minutes.toLocaleString(undefined,{minimumIntegerDigits: 2})}:${seconds.toLocaleString(undefined,{minimumIntegerDigits: 2})}`; |
There was a problem hiding this comment.
Hi Nigel, You have done great job. I did not know how to use tolocaleString and minimumIntegerDigit. I am really happy to learn from you! thanks!
There was a problem hiding this comment.
Great job getting the alarm clock to work! 🙂
I'd recommend breaking your code down using more functions - this will make it more structured and readable.
For example, instead of using an anonymous function as the first argument for setInterval, you can define it outside of setAlarm, name it something like decrementAndRenderTimer, and pass it to setInterval.
I would do that repeatedly until functions are no longer than about 4-5 lines long, and - more importantly - each function accomplishes one specific thing that can be described with the function name.
Other than that, there are a few bugs with the implementation; let me know if you are not sure how to fix those:
- When the "Set Alarm" button is pressed multiple times while the timer is running, the timer starts showing the wrong time. This happens because
setIntervalis called multiple times without callingclearInterval. - The alarm sound plays 1 second after the timer reaches 00:00.
Mandatory exercise functions built with some basic styling.
These will be updated and improved during the week.
Your Details
Homework Details