-
-
Notifications
You must be signed in to change notification settings - Fork 193
West Midlands | 25-ITP-Sept | Mustaf Asani | Sprint 3 | Feature/alarmclock #921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| playAlarm(); | ||
| } | ||
| displayTime(inputTime); | ||
| if (timer) clearInterval(timer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What else should also be reset before starting a new countdown?
| function setAlarm() { | ||
| inputTime = Number(document.querySelector("#alarmSet").value); | ||
|
|
||
| if (Number.isInteger(inputTime) && !isNaN(inputTime) && inputTime >= 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the checks is redundant.
| } else if (inputTime === 0) { | ||
| displayTime(inputTime); | ||
| playAlarm(); | ||
| } | ||
| displayTime(inputTime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When inputTime is zero, some of your code are unnecessary executed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could consider replacing
<h1 id="timeRemaining">Time Remaining: 00:00</h1>
by
<div id="timeRemaining">Time Remaining: <span id="theTime">00:00</span></div>
Suggestion: Use AI to find out why the latter is better.
Learners, PR Template
Self checklist
Changelist
Added functions to alarm to make the timer count down from input time and alarm to off when it reaches 0.