Skip to content

Birmingham | ITP-Jan-26 | Ayodeji Ayorinde | Sprint 3| Alarm Clock#1128

Open
Ayogit1 wants to merge 1 commit intoCodeYourFuture:mainfrom
Ayogit1:Alarm-clock
Open

Birmingham | ITP-Jan-26 | Ayodeji Ayorinde | Sprint 3| Alarm Clock#1128
Ayogit1 wants to merge 1 commit intoCodeYourFuture:mainfrom
Ayogit1:Alarm-clock

Conversation

@Ayogit1
Copy link
Copy Markdown

@Ayogit1 Ayogit1 commented Mar 28, 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

Completed alarm clock task

@Ayogit1 Ayogit1 added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Mar 28, 2026
@magarpratik magarpratik added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Apr 3, 2026
Copy link
Copy Markdown

@magarpratik magarpratik left a comment

Choose a reason for hiding this comment

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

Really great work! 🙌

The code is very easy to read and understand. I found the variable names quite descriptive and the code well structured.

I've just added a few comments highlighting minor points. Overall the PR looks very good! 👍

@@ -1,4 +1,49 @@
function setAlarm() {}
//function setAlarm() {}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let's remove this.

Comment on lines +34 to +46
/**
* Helper function to format the time as 00:00
*/
function updateDisplay(totalSeconds, displayElement) {
const minutes = Math.floor(totalSeconds / 60);
const seconds = totalSeconds % 60;

// Converts numbers to strings and pads with a leading zero if needed
const formattedMinutes = minutes.toString().padStart(2, "0");
const formattedSeconds = seconds.toString().padStart(2, "0");

displayElement.innerText = `Time Remaining: ${formattedMinutes}:${formattedSeconds}`;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This logic looks good. 👍

Comment on lines +10 to +11
// Safety check: Ensure input is a number and greater than 0
if (!alarmInput || alarmInput <= 0) return;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This check technically allows non-numeric string inputs (e.g. "hello") to pass through. It’s probably fine since the input field appears restricted to numbers, but worth noting.

Comment on lines +5 to +32
function setAlarm() {
// 1. Get the input value and the display element
const alarmInput = document.getElementById("alarmSet").value;
const timeRemainingDisplay = document.getElementById("timeRemaining");

// Safety check: Ensure input is a number and greater than 0
if (!alarmInput || alarmInput <= 0) return;

let timeRemaining = parseInt(alarmInput);

// 2. Clear any existing timers to prevent "speeding up" if clicked multiple times
clearInterval(countdownInterval);

// 3. Initial update so the user sees the time immediately
updateDisplay(timeRemaining, timeRemainingDisplay);

// 4. Start the countdown logic
countdownInterval = setInterval(() => {
timeRemaining -= 1;
updateDisplay(timeRemaining, timeRemainingDisplay);

// 5. Trigger the alarm and stop the counter when 0 is reached
if (timeRemaining <= 0) {
clearInterval(countdownInterval);
playAlarm();
}
}, 1000);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It seems one of the A/C is missing:

Given the alarm is set with a time of 00:10
When the timer reaches 00:00
Then the background colour should change
And the alarm sound should play

Could you look into it?

@magarpratik magarpratik added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants