Skip to content

Conversation

@AhmadHmedann
Copy link

@AhmadHmedann AhmadHmedann commented Dec 5, 2025

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

I have change the title in index.hml and update the code in alarmclock.js

Questions

I know it’s a silly question. They said this task should take 4 hours, but it took me at least 8. Is that normal? I also looked at some completed PRs to get a few clues.

@github-actions
Copy link

github-actions bot commented Dec 5, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@AhmadHmedann AhmadHmedann added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 5, 2025
@github-actions
Copy link

github-actions bot commented Dec 5, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 5, 2025
@AhmadHmedann AhmadHmedann added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 5, 2025
@github-actions
Copy link

github-actions bot commented Dec 5, 2025

Your PR description contained template fields which weren't filled in.

Check you've ticked everything in the self checklist, and that any sections which prompt you to fill in an answer are either filled in or removed.

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@github-actions github-actions bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 5, 2025
@AhmadHmedann AhmadHmedann added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Dec 5, 2025
@jaymes15 jaymes15 self-requested a review December 6, 2025 05:44
@jaymes15 jaymes15 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 Dec 6, 2025
@@ -1,4 +1,41 @@
function setAlarm() {}
let timerId = null;
Copy link

Choose a reason for hiding this comment

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

✔ Good: clear global state variables.

let timerId = null;
let remainingSeconds = 0;

function updateDisplay() {
Copy link

Choose a reason for hiding this comment

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

Good separation of display logic


function updateDisplay() {
let minutes = String(Math.floor(remainingSeconds / 60)).padStart(2, "0");
let seconds = String(remainingSeconds % 60).padStart(2, "0");
Copy link

Choose a reason for hiding this comment

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

Use const instead of let for minutes and seconds because they are never reassigned.

let remainingSeconds = 0;

function updateDisplay() {
let minutes = String(Math.floor(remainingSeconds / 60)).padStart(2, "0");
Copy link

Choose a reason for hiding this comment

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

Proper time formatting with padStart()

Nice One!

).textContent = `Time Remaining: ${minutes}:${seconds}`;
}

function startCountdown() {
Copy link

Choose a reason for hiding this comment

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

Good function name — clear purpose.

function startCountdown() {
if (remainingSeconds < 0) remainingSeconds = 0;
timerId = setInterval(() => {
updateDisplay();
Copy link

Choose a reason for hiding this comment

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

This runs before decrementing remainingSeconds, causing the countdown to visually lag by one second.

timerId = setInterval(() => {
updateDisplay();

if (remainingSeconds <= 0) {
Copy link

Choose a reason for hiding this comment

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

The sequence of logic in this if block would cause some issues.
This is the order you are following currently:

  • The timer checks for zero before subtracting.
  • So the alarm plays one second late.
  • Also remainingSeconds becomes -1 often.

Why not Subtract first, then check?

}

function setAlarm() {
const input = document.getElementById("alarmSet");
Copy link

Choose a reason for hiding this comment

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

I think we can have better validation in setAlarm function.

  • If input is negative
  • if input is a string of text
  • you did a good job checking for empty string

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for your feedback — it was really helpful, and I understood what you meant straight away.
In the HTML file, Their is a validation rule using the type attribute in Index.html file. Should I always treat HTML and JavaScript as separate layers and include validation in both?

@jaymes15
Copy link

jaymes15 commented Dec 6, 2025

@AhmadHmedann
Answering your question here
I know it’s a silly question. They said this task should take 4 hours, but it took me at least 8. Is that normal? I also looked at some completed PRs to get a few clues.

It’s totally fine that it took you 8 hours instead of the suggested 4. As you keep coding and solving more problems, you’ll naturally get faster and more confident. Progress comes with practice, so don’t worry about the extra time — it’s part of the learning process.

@jaymes15 jaymes15 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 Dec 6, 2025
…remainSecond before calling updateDisplay \n handle zero and negative-input
@AhmadHmedann AhmadHmedann 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 Dec 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants