-
-
Notifications
You must be signed in to change notification settings - Fork 219
West Midlands | 25-ITP-Sept | Baba Yusuf | Sprint 3 | Alarm Clock #891
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
West Midlands | 25-ITP-Sept | Baba Yusuf | Sprint 3 | Alarm Clock #891
Conversation
cjyuan
left a comment
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.
Can you also keep this branch clean?
| function format(num) { | ||
| if (num < 10) return "0" + num; | ||
| return num; | ||
| } |
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.
Why not just use String.prototype.padStart()?
| heading.innerText = | ||
| "Time Remaining: " + | ||
| format(Math.floor(time / 60)) + | ||
| ":" + | ||
| format(time % 60); |
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.
This code is identical to those on lines 16-20 -- a hint that indicates we could simplify the code.
|
|
||
| const heading = document.getElementById("timeRemaining"); | ||
|
|
||
| clearInterval(intervalId); |
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.
In addition to clearing intervalId, can you think of anything else that should also be reset before a new countdown starts?
|
|
||
| function setAlarm() { | ||
| const input = document.getElementById("alarmSet"); | ||
| let time = Number(input.value); |
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.
Can you think of any potential invalid input that you should prevent?
Learners, PR Template
Self checklist
Changelist
I implemented the setAlarm() function as per instruction
Checked for update to the testing framework by running npm install
Updated the title in the index.html file as per task instruction
Questions