Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | Alarm Clock#1064
Sheffield | 26-ITP-jan | Richard Frimpong | Sprint 3 | Alarm Clock#1064Richiealx wants to merge 4 commits intoCodeYourFuture:mainfrom
Conversation
cjyuan
left a comment
There was a problem hiding this comment.
When input is 1, the alarm is played one second later -- an expected behavior.
However, when input is 0, the alarm is also played one second later (instead of being played immediately). Can you make the app's behaviour more consistent?
Sprint-3/alarmclock/alarmclock.js
Outdated
| // Stop any previous countdown before starting a new one | ||
| stopCountdown(); | ||
|
|
||
| // Stop any alarm sound that may already be playing | ||
| pauseAlarm(); | ||
|
|
||
| // Reset the page state for a new alarm | ||
| resetBackground(); |
There was a problem hiding this comment.
Could consider
- Including these three operations into a
resetAll()function, and - Call the function to reset the application states as soon as the "Start" button is clicked (even when the input is incorrect).
There was a problem hiding this comment.
Thank you for the feedback.
I’ve now updated the alarm clock based on your comments:
- I changed the behaviour so that when the input is
0, the alarm is triggered immediately instead of one second later. - I combined the background update logic into a single function that adds or removes the CSS class based on a parameter.
- I created a
resetAll()function to group the reset operations together, and I now call it as soon as the "Set Alarm" button is clicked.
I also cleaned up the alarm clock code so the duplicated starter functions were removed and the final file structure is now clear and consistent.
I tested the app again and confirmed the updated behaviour works as expected.
This comment has been minimized.
This comment has been minimized.
|
Please revert the changes made in the Sprint-2 folder. |
9351328 to
23ea297
Compare
|
Thank you for your feedback. I identified that I had accidentally committed changes to the wrong branch, which caused unrelated files to appear in this PR. I have now cleaned the branch so that this PR only includes changes within I also implemented the suggested improvements:
|
|
Changes look good. Well done. |
Learners, PR Template
Self checklist
Changelist
This PR implements the Sprint 3 Alarm Clock app.
The application starts with the heading showing
Time Remaining: 00:00and no alarm sound playing.When the user enters a number of seconds and clicks the "Set Alarm" button, the heading updates immediately in
mm:ssformat. The countdown then decreases by one second every 1000 ms.When the timer reaches
00:00, the background colour changes and the alarm sound starts playing continuously. Clicking the "Stop Alarm" button stops the alarm sound.I also added logic to clear any existing timer before starting a new one, reset the background state when a new alarm is set, and format the display consistently.
The app was tested in the browser to confirm:
00:00I also ran the provided tests for the alarm clock task, and all tests passed successfully.
Questions
No questions at this time.