Skip to content

Conversation

@M-Abdoon
Copy link

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

Alarm clock app exercise done.

Questions

No questions so far, thank you.

@M-Abdoon M-Abdoon added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 15, 2025
@github-actions
Copy link

Your PR couldn't be matched to an assignment in this module.

Please check its title is in the correct format, and that you only have one PR per assignment.

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

1 similar comment
@github-actions
Copy link

Your PR couldn't be matched to an assignment in this module.

Please check its title is in the correct format, and that you only have one PR per assignment.

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

@M-Abdoon M-Abdoon changed the title Glasgow | 25-ITP-Sep | Mohammed Abdoon | Sprint 3| alarmClockApp Glasgow | 25-ITP-Sep | Mohammed Abdoon | Sprint 3| alarm Clock Nov 15, 2025
@M-Abdoon M-Abdoon changed the title Glasgow | 25-ITP-Sep | Mohammed Abdoon | Sprint 3| alarm Clock Glasgow | 25-ITP-Sep | Mohammed Abdoon | Sprint 3| Alarm Clock Nov 15, 2025
@AbogeJr AbogeJr 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 Nov 22, 2025
Copy link

@AbogeJr AbogeJr left a comment

Choose a reason for hiding this comment

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

Overall nice work @M-Abdoon. I've highlighted a few improvements you could make in the comments 👍

}, 1000);
}

function toMMSS (seconds) {
Copy link

Choose a reason for hiding this comment

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

I think this function could have a more descriptive name? Maybe something that easily describes what the function does.

Copy link
Author

Choose a reason for hiding this comment

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

True. I changed the name to 'formatTimeMMSS()' so it shows what it actually does.

timeRemainingHTML.innerHTML = `Time Remaining: ${toMMSS(secondsLeft)}`;
pageTitle.innerHTML = `Time Remaining: ${toMMSS(secondsLeft)}`;

document.getElementById("pause").addEventListener("click", () => {
Copy link

Choose a reason for hiding this comment

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

I'm not sure this is the best place to initialize an event listener. Please check it out to see why it would be problematic.

Copy link
Author

Choose a reason for hiding this comment

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

I would be problematic because it keeps adding a new listener every 100 ms. I moved the event out of setInterval().

let secondsLeft = Math.max(0, Math.ceil(timeDifference / 1000));

timeRemainingHTML.innerHTML = `Time Remaining: ${toMMSS(secondsLeft)}`;
pageTitle.innerHTML = `Time Remaining: ${toMMSS(secondsLeft)}`;
Copy link

Choose a reason for hiding this comment

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

I think there is a better way to change the title of a html document.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I now used this way:
document.title =
instead of:
pageTitle.innerHTML =

function setAlarm() {}
function setAlarm() {
const timer = Number(document.querySelector("#alarmSet").value);
const timeRemainingHTML = document.querySelector("#timeRemaining");
Copy link

Choose a reason for hiding this comment

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

Maybe we can have a better name for the variable here since we are referencing a single element?

Copy link
Author

Choose a reason for hiding this comment

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

I changed it to ' timeRemainingEl ' which means ' time remaining element '. I think that's a better way to name it.

const pageTitle = document.querySelector("title");

let targetTime = new Date().getTime() + timer * 1000;
console.log(targetTime);
Copy link

Choose a reason for hiding this comment

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

This is fine during development but typically we clean them up before submission of work.

Copy link
Author

Choose a reason for hiding this comment

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

exactly! I removed it.

const doAlarm = setInterval( () => {
let timeThisSecond = new Date().getTime();
let timeDifference = targetTime - timeThisSecond;
let secondsLeft = Math.max(0, Math.ceil(timeDifference / 1000));
Copy link

Choose a reason for hiding this comment

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

Good job using the Math functions here. 👌
Although, a minor improvement you should look into is when to use let to initialize variables.

Copy link
Author

@M-Abdoon M-Abdoon Nov 22, 2025

Choose a reason for hiding this comment

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

Thank you ^^.
I replaced 'let' with 'const' since we won't need to change their values.

@AbogeJr AbogeJr 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 Nov 22, 2025
@M-Abdoon M-Abdoon 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 Nov 22, 2025
@M-Abdoon
Copy link
Author

Overall nice work @M-Abdoon. I've highlighted a few improvements you could make in the comments 👍

Thank you so much for your review.
I made the required changes.

@AbogeJr AbogeJr 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 Nov 22, 2025
Copy link

@AbogeJr AbogeJr left a comment

Choose a reason for hiding this comment

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

Almost there 👌

Comment on lines +32 to +36
document.getElementById("pause").addEventListener("click", () => {
pauseAlarm();
clearInterval(doAlarm);
});

Copy link

Choose a reason for hiding this comment

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

Not quite. We're not supposed to edit the code in this section. Please check again.

Copy link
Author

Choose a reason for hiding this comment

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

Done. I changed its place.

const secondsLeft = Math.max(0, Math.ceil(timeDifference / 1000));

timeRemainingEl.innerHTML = `Time Remaining: ${formatTimeMMSS(secondsLeft)}`;
document.title = `Time Remaining: ${formatTimeMMSS(secondsLeft)}`;
Copy link

@AbogeJr AbogeJr Nov 22, 2025

Choose a reason for hiding this comment

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

Almost there but please check the first instruction about the "title" on the alarmclock readme.md

Copy link
Author

Choose a reason for hiding this comment

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

ah yes. I should have changed the page title so I put a default one and then it changes when the user clicks on the button.
I have set the title.

Copy link

@AbogeJr AbogeJr Nov 22, 2025

Choose a reason for hiding this comment

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

Okay I see the instruction is a little ambiguous, could be worded better but generally you won't want to update the page title, at least not in this way (every second).
image

ref:

First off, once you've branched off main, then update the title element in index.html to "Alarm clock app" You will need to write your implementation in alarmclock.js.

Copy link
Author

Choose a reason for hiding this comment

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

Should it maybe be like " Counting down ... " once the user clicks on the button? or maybe it should not change at all?

Copy link

Choose a reason for hiding this comment

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

Yes. The title (on the browser tab) should remain as it is. The title (h1 inside the page should update)

Copy link
Author

Choose a reason for hiding this comment

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

Ok. I just updated the code, now the page title on the browser tab does not change anymore.

@AbogeJr AbogeJr 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 Nov 22, 2025
@M-Abdoon
Copy link
Author

Thank you so much.
changes have been made.

@M-Abdoon M-Abdoon 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 Nov 22, 2025
@AbogeJr AbogeJr 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 Nov 22, 2025
Copy link

@AbogeJr AbogeJr left a comment

Choose a reason for hiding this comment

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

Looks good. One last thing, please check the <title> in the alarmclock.html

@AbogeJr AbogeJr 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 Nov 22, 2025
@M-Abdoon
Copy link
Author

I changed the title. Thank you.

@M-Abdoon M-Abdoon 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 Nov 22, 2025
@AbogeJr AbogeJr 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 Nov 22, 2025
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