Skip to content

London | 26-ITP-May | Damilola Odumosu| Sprint 3 | Alarm Clock - #1360

Open
d-odumosu wants to merge 1 commit into
CodeYourFuture:mainfrom
d-odumosu:coursework/sprint-3/alarmclock
Open

London | 26-ITP-May | Damilola Odumosu| Sprint 3 | Alarm Clock#1360
d-odumosu wants to merge 1 commit into
CodeYourFuture:mainfrom
d-odumosu:coursework/sprint-3/alarmclock

Conversation

@d-odumosu

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

@d-odumosu d-odumosu added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Data-Groups The name of the module. 📅 Sprint 3 Assigned during Sprint 3 of this module labels Aug 2, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Code works fine if a user only clicks the "Set Alarm" button once. However, if the user enters a time and then clicks the "Set Alarm" button multiple times, the countdown clock will not display properly. Could you fix the issue?

  • Currently when starting a new countdown, the application does not always return to a clean initial state, which can lead to inconsistent behaviour between runs.

    Note: a user may not click the "Stop" button first before starting a new count down.

@@ -1,4 +1,28 @@
function setAlarm() {}
const input = document.getElementById("alarmSet");
const timeDisplay = document.querySelector("span");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

span is a fairly generic element, so using it as the selector for the time display can make the code less specific and more fragile. Could you find out why selecting a span for this purpose is not considered good practice, and update the selector accordingly?

Comment on lines +15 to +19
let remainingMinutes = Math.floor(timeInput / 60);
let remainingSeconds = timeInput % 60;
remainingMinutes = remainingMinutes.toString().padStart(2, "0");
remainingSeconds = remainingSeconds.toString().padStart(2, "0");
timeDisplay.textContent = `${remainingMinutes}:${remainingSeconds}`;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code on lines 15-19 is very similar to those on lines 6-11.
To adhere to the DRY principle, could you refactor the repeated code into a reusable function?

const timeDisplay = document.querySelector("span");

function setAlarm() {
let timeInput = Number(input.value);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some input values could make your app behave abnormally. Could you add code to sanitise or reject them?

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Data-Groups The name of the module. Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants