-
-
Notifications
You must be signed in to change notification settings - Fork 157
ZA | ITP-MAY-25 | Shannon Davids | Data Groups-Sprint-3 | AlarmClock #758
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?
ZA | ITP-MAY-25 | Shannon Davids | Data Groups-Sprint-3 | AlarmClock #758
Conversation
Sprint-3/alarmclock/alarmclock.js
Outdated
const mins = Math.floor((sec % 3600) / 60); | ||
const secs = sec % 60; | ||
return `${String(hrs).padStart(2, "0")}:${String(mins).padStart( | ||
2, | ||
"0" | ||
)}:${String(secs).padStart(2, "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.
Is this function needed in the app? If not, it should be removed to keep the code clean.
Sprint-3/alarmclock/alarmclock.js
Outdated
if (timeRemaining <= 0) { | ||
clearInterval(countdownInterval); | ||
updateDisplay(); | ||
playAlarm(); | ||
} else { | ||
updateDisplay(); | ||
} |
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.
Regardless of the condition on line 31, the app is going to call updateDisplay()
. So we could factor out the function call and call the function once outside the if block.
Sprint-3/alarmclock/alarmclock.js
Outdated
const input = document.getElementById("alarmSet"); | ||
const seconds = parseInt(input.value); | ||
|
||
if (isNaN(seconds) || seconds <= 0) { | ||
alert("Please enter a valid number of seconds."); | ||
return; | ||
} | ||
|
||
clearInterval(countdownInterval); // Stop any existing countdown |
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 also consider stopping the flashing background and the alarm sound when a new countdown is set.
Changes look good! |
Learners, PR Template
Self checklist
Changelist
Briefly explain your PR.
Questions
Ask any questions you have for your reviewer.