- 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 168
Glasgow | 25-ITP-SEP | Shreef Ibrahim | Sprint 3| Alarm clock app #795
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really great start but there are couple of issues to address.
        
          
                Sprint-3/alarmclock/alarmclock.js
              
                Outdated
          
        
      | function setAlarm() { | ||
| const timeRemaining = document.getElementById("timeRemaining"); | ||
| const alarmSet = document.getElementById("alarmSet").value; | ||
| alarmTime = parseInt(alarmSet); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to add some value validation to ensure that you get integer and this line doesn't throw an error.
        
          
                Sprint-3/alarmclock/alarmclock.js
              
                Outdated
          
        
      | } else { | ||
| clearInterval(countDown); | ||
| playAlarm(); | ||
| document.body.style.background = "#e14343"; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Background color is not set to red when alarmTime reaches 0. You might want to double check this logic
        
          
                Sprint-3/alarmclock/alarmclock.js
              
                Outdated
          
        
      | "0" | ||
| )}:${String(seconds).padStart(2, "0")}`; | ||
| } | ||
| // DO NOT EDIT BELOW HERE | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are missing stopAlarm function implementation. Please double check the acceptance criteria for this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @shreefAhmedM! Really great work! I have just two small comments and it's good to go.
Optionally, when you have time, I would like you to think how you could rewrite this cleaner without having many variables in a global scope. You can pass parameters to event listener functions or perhaps restructure your functions in a way that allows passing variables as parameters.
| }); | ||
| // set up alarm | ||
| function setAlarm() { | ||
| const val = parseInt(inputField.value); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if inputField.value is empty? Can you try starting the alarm without entering anything into input field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When inputField.value is empty, the  parseInt("") returns NaN,
So I have validated the condition if the value is NaN, Undefined , null or less than 0 , i used return  it will stop any further execution so no nothing will happen. I can throw an error message instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean you already have it in your code or you are going to push? I don't see validation against NaN, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have already used it thing i did not push properly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah okay, that happens 🙂
|  | ||
| // stop or start flashing | ||
| let flashingInterval; | ||
| const flashingColors = ["#FF4136", "#2ECC40", "#0074D9", "#FFDC00"]; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to keep variable local if it's not used elsewhere. Makes your code cleaner and reduces possibility of bugs due to accidental change to your variable.
| Looks good to me, good job! | 
Self checklist
Here is a basic implementation of an alarm clock app using HTML and JavaScript