Sheffield | ITP-Jan-26 | Mahammad Osman | Sprint 3 | Alarm Clock#1162
Sheffield | ITP-Jan-26 | Mahammad Osman | Sprint 3 | Alarm Clock#1162Darkidd77 wants to merge 3 commits intoCodeYourFuture:mainfrom
Conversation
| const headingElement = document.getElementById("timeRemaining"); | ||
|
|
||
| if (!inputElement.value) { | ||
| return; |
There was a problem hiding this comment.
It's important to validate user input.
What happens if a user enters a negative value?
How could you give feedback to the user about the input not being valid?
There was a problem hiding this comment.
Yes, I realised that I have to validate the input to avoid unexpected actions from the code, as if it's negative values it trigger the alarm as its less than zero, i did added a check after parsing the input to make sure its not negative and not a NaN and return a message informing the user to input a valid value. Thank you
There was a problem hiding this comment.
You could remove the condition for checking "!inputElement.value" now and save some line of codes.
| }, 1000); | ||
| } | ||
|
|
||
| function flashScreen() { |
There was a problem hiding this comment.
Nice bonus implementation of the flashing screen
Learners, PR Template
Self checklist
Changelist
setAlarmfunction.setInterval(1000ms delay).MM:SSusing.padStart(2, '0').clearIntervalboth when the timer hits zero, and if the user clicks "Set Alarm" while a timer is already running.