Countdown | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Countdown

Why is my seconds number going in the negatives and my hour number not working? https://code.sololearn.com/WlQITx1G8Ajm/?ref=app

7th Aug 2022, 3:51 PM
Junior
Junior - avatar
6 Answers
+ 1
At line 31 & 37, I think... minutePrompt = 60; secondPrompt = 60; That worked for me. You just have second = 60 and minute = 60. They are the variable labels you used.
7th Aug 2022, 6:38 PM
Ausgrindtube
Ausgrindtube - avatar
+ 1
Damn it's too late for me to play around now. I'll try tomorrow. My idea would be to check why the minutes and seconds work and not the hours. Surely there's something to add to make it work. Maybe you need to include in your if statements a check that each number above it is greater than 0..?
7th Aug 2022, 9:26 PM
Ausgrindtube
Ausgrindtube - avatar
0
You haven't specified a condition where the numbers should be positive only. So add a condition beffore all of others like: if hours<0 || minutes<0: do_the_ending_thing();
7th Aug 2022, 6:17 PM
Ervis Meta
Ervis Meta - avatar
0
i did that but still not workinf
7th Aug 2022, 6:28 PM
Junior
Junior - avatar
0
This is a sample made in Python: https://code.sololearn.com/c945fGpS8I2H/?ref=app You can implement this aproach in js.
8th Aug 2022, 1:02 AM
Ervis Meta
Ervis Meta - avatar
- 1
oh yes i forgot to put prompt there. but when my hour thing === 0 the minute and seconds dont work
7th Aug 2022, 6:47 PM
Junior
Junior - avatar