Skip to content

London | 26-ITP-Jan | Karla Grajales | Sprint 3 | Alarm Clock App#1183

Open
Grajales-K wants to merge 12 commits intoCodeYourFuture:mainfrom
Grajales-K:Alarm-Clock-App
Open

London | 26-ITP-Jan | Karla Grajales | Sprint 3 | Alarm Clock App#1183
Grajales-K wants to merge 12 commits intoCodeYourFuture:mainfrom
Grajales-K:Alarm-Clock-App

Conversation

@Grajales-K
Copy link
Copy Markdown

@Grajales-K Grajales-K commented Apr 6, 2026

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

This application features a dynamic countdown engine built with JavaScript that accurately converts numerical user input into a mm:ss display format. It integrates a multisensory alert system that triggers both a continuous audio track and a synchronised disco background effect using random RGB generation once the alarm reaches zero.

The core logic was optimised for test-driven development, implementing a repetition counter to prevent infinite loops and ensure all Jest unit tests pass successfully. The project includes an input validation to handle non-numeric values, ensuring a stable and functional application.

@Grajales-K Grajales-K added 🏕 Priority Mandatory This work is expected 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Submit:PR javascript Pull requests that update javascript code labels Apr 6, 2026
@Grajales-K Grajales-K added the Module-Data-Groups The name of the module. label Apr 7, 2026
@@ -1,8 +1,59 @@
function setAlarm() {}
let countdown;
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.

Consider renaming countdown to countdownInterval or intervalId since this stores the interval ID, not the countdown value.

Comment on lines +4 to +5
clearInterval(countdown);
document.body.style.backgroundColor = "white";
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 behavior between runs.

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

You can also consider introducing a dedicated reset function to return the app to a clean initial state to help ensure consistency. There are few places in this script you can call this reset function instead of repeating the reset logic.

Comment on lines +7 to +12
let inputTime = Number(document.getElementById("alarmSet").value);

if (isNaN(inputTime) || inputTime <= 0) {
alert("Please type or select your time 👇⏰");
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.

What type of numbers should inputTime be? (Currently some input value can corrupt the timer display)

Comment on lines +46 to +48
let display = `Time Remaining: ${minutes
.toString()
.padStart(2, "0")}:${remainingSeconds.toString().padStart(2, "0")}`;
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.

Having a long expression within a template string literal can make the code harder to read.
Better to use an inline function to perform the repeated task, or to store the formatted
values in variables first.

Comment on lines +24 to +34
let repetitions = 0;
countdown = setInterval(() => {
document.body.style.backgroundColor = `rgb(
${Math.floor(Math.random() * 256)},
${Math.floor(Math.random() * 256)},
${Math.floor(Math.random() * 256)})`;
repetitions++;

if (repetitions > 100) {
clearInterval(countdown);
}
Copy link
Copy Markdown
Contributor

@cjyuan cjyuan Apr 8, 2026

Choose a reason for hiding this comment

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

It is best practice to separate presentation logic from application logic.
Can you either implementing the background animation in CSS or move the code that perform the animation into a separate function?

Note: CSS random() function is still in experimental stage. With pure CSS, we can only cycle through a pre-defined set of colors (e.g. https://codepen.io/beben-koben/pen/eYPNew)

If you are implementing this purely in CSS, you can consider defining a CSS class, and use classList.toggle() to apply/remove the style. For example,

document.body.classList.toggle("alarm-activated", true);  // apply style
document.body.classList.toggle("alarm-activated", false); // remove style

@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 Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update javascript code Module-Data-Groups The name of the module. 🏕 Priority Mandatory This work is expected Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 3 Assigned during Sprint 3 of this module Submit:PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants