Skip to content

Sheffield|May-2025|Sheida Shabankari|Module-Data -Groups| Sprint-3|Alarm Clock #631

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 15 commits into
base: main
Choose a base branch
from

Conversation

sheida-shab
Copy link

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

I have done all requirements for setting an alarm clock step by step and passed all the tests.

@sheida-shab sheida-shab added the Needs Review Participant to add when requesting review label Jul 16, 2025
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

  • Code works fine if a user only clicks the "Set Alarm" button once.
    However, if the user enters a time and then clicks the "Set Alarm" button multiple times, the countdown clock will not display properly.
    Can you fix the issue?

  • Some of the function definitions appear twice. Can you remove the unwanted copies?

  • We should respect instructions like DO NOT EDIT BELOW HERE; it is usually there for a reason. If you are curious about why, you can ask ChatGPT Why should programmers respect "DO NOT EDIT BELOW HERE" instruction in a file? (You don't have to undo the changes you made this time, I just want to raise your awareness)

@@ -1,5 +1,98 @@
function setAlarm() {}
var flashColor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why use var instead of let?

Copy link
Author

Choose a reason for hiding this comment

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

I used var out of old habit because I used to work with it before, and I wasn’t really paying attention to why I was using it.

Comment on lines +6 to +9
if (inputTime <= 0 || isNaN(inputTime)) {
alert("invalid input!!!");
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Some unusual input values that can make your app behave abnormally can still pass this check. Can you add code to sanitise them?

Copy link
Author

Choose a reason for hiding this comment

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

I have already handled empty input, negative numbers, decimals, and zero values. Since the input field is defined as type 'number', non-numeric inputs are also prevented altogether. The only thing left, in my opinion, is controlling very large numbers. Do you think it's necessary to set a limit on the numeric value that can be entered? Also, I don’t have any other ideas about unusual inputs that might cause issues—if possible, could you please guide me on that?"

Comment on lines 27 to 28
let min = String(Math.floor(inputTime / 60)).padStart(2, "0");
let sec = String(inputTime % 60).padStart(2, "0");
Copy link
Contributor

Choose a reason for hiding this comment

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

Can consider declaring these two variables with const because they won't be reassigned any value.

Copy link
Author

@sheida-shab sheida-shab Jul 18, 2025

Choose a reason for hiding this comment

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

Sure,you are right.I fixed it.

Comment on lines 48 to 54
document.getElementById("stop").style.backgroundColor = "rgb(191, 115, 47)";
document.body.style.backgroundColor = "rgb(218, 178, 119)";
let flashColor=setInterval(() => {
if(document.body.style.backgroundColor === "rgb(218, 178, 119)"){
document.body.style.backgroundColor = "white";
}else{
document.body.style.backgroundColor = "rgb(218, 178, 119)";
Copy link
Contributor

Choose a reason for hiding this comment

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

Could consider preparing several CSS classes in a CSS file and then assign/remove CSS class to these element to change their appearance. This way, if we want to change the styles (including color), we don't have to modify the JS code.

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 guidance, I understand, but due to lack of time, I’m unable to make this change right now. If you don’t mind, and there’s no problem with it, I’d like to leave it as is for now.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review and removed Needs Review Participant to add when requesting review labels Jul 17, 2025
@sheida-shab
Copy link
Author

I fixed the issues you mentioned. Now, even if the user clicks the “Set Alarm” button multiple times, the timer works properly . I also removed the duplicate functions .

I asked ChatGPT about the DO NOT EDIT BELOW HERE part and now I get why we shouldn’t touch that section.

Thanks for your guidance—it really helped me improve the code and learn new things.

@sheida-shab sheida-shab added Needs Review Participant to add when requesting review and removed Needs Review Participant to add when requesting review labels Jul 18, 2025
@sheida-shab sheida-shab added the Needs Review Participant to add when requesting review label Jul 18, 2025
@@ -1,85 +1,26 @@
var flashColor;
let flashColor, secondsInterval, inputTime;
Copy link
Contributor

Choose a reason for hiding this comment

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

  • The inputTime in function setAlarm() is not related to the inputTime parameter in updateDisplayTime(). In both functions, the variable/parameter is used locally, so inputTime should not be declared at in the top-level scope.

  • Also, since inputTime in only assigned once in function setAlarm(), it could better be declared using const inside that function.

Copy link
Author

Choose a reason for hiding this comment

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

I fixed the issue.

Comment on lines 15 to 25
let remainingTime = inputTime;
updateDisplayTime(remainingTime);

secondsInterval=setInterval(() => {
remainingTime--;
updateDisplayTime(remainingTime);
if (remainingTime === 0) {
clearInterval(secondsInterval);
playAlarm();
}
}, 1000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Indentation is a bit off.

Copy link
Author

Choose a reason for hiding this comment

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

I fixed it.

Copy link
Contributor

Choose a reason for hiding this comment

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

This file should not be included in the alarm-clock PR. Can you revert the change made to this file?

Copy link
Author

Choose a reason for hiding this comment

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

I reverted the changes.

@cjyuan cjyuan removed the Needs Review Participant to add when requesting review label Jul 19, 2025
@sheida-shab sheida-shab added the Needs Review Participant to add when requesting review label Jul 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review Participant to add when requesting review Reviewed Volunteer to add when completing a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants