Skip to content

NW | ITP-May-25 | Geraldine Edwards | Module-Data-Groups | Sprint-3 | Alarm Clock App #585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Geraldine-Edwards
Copy link

@Geraldine-Edwards Geraldine-Edwards commented Jul 11, 2025

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Added user functionality to the Alarm Clock App using Javascript.

Questions

Ask any questions you have for your reviewer.

@Geraldine-Edwards Geraldine-Edwards added the Needs Review Participant to add when requesting review label Jul 11, 2025
Copy link

@HappyCoder5114 HappyCoder5114 left a comment

Choose a reason for hiding this comment

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

please see the below comments!

const minutes = Math.floor(time / 60)
.toString()
.padStart(2, "0"); // calculate the minutes and format it to 2 digits
const seconds = (time % 60).toString().padStart(2, "0"); // calculate the seconds and format it to 2 digits

Choose a reason for hiding this comment

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

In general, the code looks good. here is something you could improve. const minutes = Math.floor(timeInSeconds / 60)
.toString()
.padStart(2, "0"); this has been used multiple time, so considering use a helper function to abstract this.

Copy link
Author

Choose a reason for hiding this comment

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

oh yes of course, I was so busy being focused on getting the pull request completed I totally forgot to refactor the code :( - I have made the changes now and it is much better, thank you!

// check for invalid inputs and update the <h1> element with an error message if the input is invalid
if (!Number.isInteger(timeInSeconds) || timeInSeconds < 0) {
alert("Please enter a valid number of seconds!");
return; // stop the code if the input is invalid

Choose a reason for hiding this comment

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

if (typeof timeInSeconds !== "number" || timeInSeconds < 0) {
throw new Error("Invalid input: timeInSeconds must be a non-negative number");
} you could promote will a more specific alert message.

Copy link
Author

Choose a reason for hiding this comment

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

I completely understand where you are coming from there. I suppose when I was writing the invalid input validation I was thinking along the lines of the UX for the user - I considered the system error approach but I believe it would crash the app. I have adjusted the message, however; it is now alert("Please enter a whole number of seconds (like 60 for 1 minute)")
I am curious to know which would be the better approach though in a real-world project- send an alert to the user or throw a system error?
Thank you :)

@HappyCoder5114
Copy link

i think both should be okay, really depands on the context. in the current one, alert would be better but the example i threw was just to show the alert information could be more informative to user.

@HappyCoder5114
Copy link

it's a bit annoying as i cant' change the label.

@illicitonion illicitonion added Reviewed Volunteer to add when completing a review and removed Needs Review Participant to add when requesting review labels Jul 16, 2025
@CameronDowner CameronDowner added Complete Volunteer to add when work is complete and review comments have been addressed and removed Reviewed Volunteer to add when completing a review labels Jul 17, 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 review comments have been addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants