Skip to content

London | 26-ITP-May | Yonatan Teklemariam | Sprint 3 | Alarm Clock - #1403

Open
Yonatanteklemariam wants to merge 6 commits into
CodeYourFuture:mainfrom
Yonatanteklemariam:Sprint-3-alarmclock
Open

London | 26-ITP-May | Yonatan Teklemariam | Sprint 3 | Alarm Clock#1403
Yonatanteklemariam wants to merge 6 commits into
CodeYourFuture:mainfrom
Yonatanteklemariam:Sprint-3-alarmclock

Conversation

@Yonatanteklemariam

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

Changelist

Implemented the alarm clock function based on the specified instruction and added some flashing effect to it

Questions

@Yonatanteklemariam Yonatanteklemariam added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Aug 7, 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.

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
Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
Comment on lines +72 to +73
document.getElementById("timeRemaining").innerText =
`Time Remaining: ${formatTime(timeLeft)}`;

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.

Could consider implement a function to display the time instead of repeating the logic several times.

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
// When the timer reaches zero
if (timeLeft <= 0) {
clearInterval(window.countdownTimer); // stop the countdown
clearInterval(flashInterval); // stop the flashing if it was running

@cjyuan cjyuan Aug 10, 2026

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 would the background be flashing when a count down was active? (Should the app prevent it from happening?)

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
Comment on lines +28 to +33
const input = document.getElementById("alarmSet").value;

// If nothing was typed, exit the function
if (!input) {
return;
}

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.

Is there any other value the app should also reject (to prevent it from behaving abnormally)?

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
Comment on lines +52 to +60
let timeLeft = totalSeconds;

// If a previous timer was running, stop it
if (window.countdownTimer) {
clearInterval(window.countdownTimer);
}

// A simple helper to turn seconds into MM:SS format
function formatTime(seconds) {

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.

Interleaving variable declarations, function definitions, and executable code makes the code harder to read and maintain. A common practice is to organise the code in the following order:

// Variable declarations

// Function definitions

// Code to be executed

Comment thread Sprint-3/alarmclock/alarmclock.js Outdated
Comment on lines +38 to +49
if (input.includes(":")) {
// Split into minutes and seconds
const parts = input.split(":");
const minutes = Number(parts[0]);
const seconds = Number(parts[1]);

// Convert everything into total seconds
totalSeconds = minutes * 60 + seconds;
} else {
// Otherwise treat the input as normal seconds
totalSeconds = Number(input);
}

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.

As the logic for converting an input string to seconds becomes more complicated, it is better to encapsulate the conversion logic in a function. Doing so makes the code easier to read and understand.

Comment thread Sprint-3/alarmclock/alarmclock.js
@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 10, 2026
…ect with css animation, fixed missing functions and broken format logic
@Yonatanteklemariam Yonatanteklemariam 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.

Comment on lines +47 to +52
const mins = Number(minsStr);
const secs = Number(secsStr);

if (
Number.isNaN(mins) ||
Number.isNaN(secs) ||

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.

What type of numbers should they be? What if the user enter 1.1:2.2 or 1.2345?


document.getElementById("stop").addEventListener("click", () => {
pauseAlarm();
stopFlashing(); // stop flashing if running

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.

An alternative would be to add another event listener that performs only `stop flashing".

@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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants