Skip to content

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

Open
d-odumosu wants to merge 4 commits 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 4 commits 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.

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
@@ -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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

i have added and id and used getelemntbyid.

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have cleaned all this up

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have added validation to the input

@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
@d-odumosu d-odumosu added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Aug 13, 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.

Changes look good, but there are a few minor improvement you could still make.

I will mark this PR as "Complete" first.

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated

function getTime() {
const time = Number(input.value);
if (!(Number.isFinite(time) && Number.isInteger(time) && time >= 1)) {

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.

This check is good.

Please note that one of the conditions is redundant.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think this Number.isFinite(time) is redundant, will make the change

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
function resetAlarm() {
clearInterval(intervalId);
intervalId = null;
timeRemaining.textContent = `Time Remaining: 00:00`;

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.

Why not call the function you have implemented for displaying time?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have implemented this.

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
Comment on lines +16 to +17
function updateTime(updatedTime) {
const time = updatedTime;

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.

Why not just name the parameter time?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

yes, i've implemented this

@cjyuan cjyuan added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. Module-Data-Groups The name of the module. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants