+ 3

Problem with 1ms setInterval [SOLVED]

I am working on a project created by golden rockstar and when I tried to make a simple stopwatch with the setInterval it didnt work. let me explain a bit. if I write setInterval(function,1000) it let it work every second, so if 1000 = 1s, 1 had to be 1ms, but it worked waaaay to slow, and now to let it work more accurate I have to add 4.5222222 milliseconds every millisecond? is it a local problem or not (my wifi is not good enough to search google since Ive got an internet problem) https://code.sololearn.com/WaS5BRKDLZEi/?ref=app

8th Aug 2018, 11:06 AM
Roel
Roel - avatar
5 Respostas
+ 1
For JavaScript, setInterval timer should be 10msec or above. You go around by making multiple setInterval to achieve 1msec timer. https://code.sololearn.com/W5pfer3My6pP/?ref=app
8th Aug 2018, 12:35 PM
Calviղ
Calviղ - avatar
+ 1
Your stopwatch works slowly
8th Aug 2018, 11:28 AM
Sousou
Sousou - avatar
+ 1
In addition, How to charge the phone?
8th Aug 2018, 11:28 AM
Sousou
Sousou - avatar
+ 1
and, can you add phone_modes (ringer, vibrer, silent)
8th Aug 2018, 11:32 AM
Sousou
Sousou - avatar
0
Calviղ Very much thanks, I didnt know that a 1ms timer was not possible using only 1 interval Sousou the phone charges itself (js line 53-113) Sousou I am gonna work on that (for example for the timer when finished) but its gonna take a while and it wont ring or vibrate if you set your real device silent
8th Aug 2018, 1:06 PM
Roel
Roel - avatar