Timer Code Problem | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
5th Mar 2019, 3:59 PM
Roman Pervutinskiy
Roman Pervutinskiy - avatar
4 Answers
+ 5
The variables that shared between functions or class must be declared in global. Not only set timer to global, other variables also needed to be global. var t, timer, hrs, min, sec; And your timer object declared in the wrong place which making the object reset whenever the timer runs. And also input.value is a string, you need to convert it to number before perform logical comparison. Check out this code https://code.sololearn.com/WOmHushIRy7k/?ref=app
5th Mar 2019, 4:33 PM
Calviղ
Calviղ - avatar
+ 2
Make timer a global variable at the top of your code
5th Mar 2019, 4:22 PM
Nathan Lewis
Nathan Lewis - avatar
+ 2
Roman Pervutinskiy what is the problem?
5th Mar 2019, 4:26 PM
Seniru
Seniru - avatar
+ 1
When I press "Start!", time is showing, but not updating.
5th Mar 2019, 4:29 PM
Roman Pervutinskiy
Roman Pervutinskiy - avatar