+ 1
The difference between this website and my code?
I was inspired to make something like this website, after I played with it for a while. The website ... Reaction Time Test. I made something similar like it. I think ms stands for Milliseconds, (right?). They use ms. And I did too, through setInterval(abc, 1). But theirs is 4 times faster than mine. Noally when you click on mine you'l get 70 - 115. On their website, you get 300 - 500 ms. The website https://www.humanbenchmark.com/tests/reactiontime My code: https://code.sololearn.com/WucfuigE2Z58/?ref=app
8 odpowiedzi
+ 1
Gordon how do I apply that in my code..
is it like....
var d = new Date();
var millisec = d.getMilliseconds
?
+ 1
Gordon I don't really understand, but Ok.
+ 1
Gordon , oh i see.
but why do i need to get the current time.. I need the milliseconds to start from 0.
When the green screen appears start counting up.
Same thing when you click on play again (blue screen), start from 0, then start counting on the green screen.
+ 1
you need to get current time twice.
The first time is when green screen appears.
the second time is when player clicks.
the difference between the two time is the time you want.
+ 1
Gordon but why current time?
Also, if I use this method isn't the milliseconds going to start over once it gets to 1000?
0
You described the problem reversely. The correct description is that your time is shorter than their time.
Because y++ is using up resources and thus the time is not counted correctly.
Use new Date() instead.
https://code.sololearn.com/WlUVtrci7y2U/?ref=app
0
don't use getMilliseconds
it will cause negative numbers.
Because after 999, it becomes 0 again.
you can use getTime()
store in variable number one when color change
store in variable number two when user clicked.
minus them to get the time difference.
0
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getMilliseconds
The getMilliseconds() method returns the milliseconds portion of the current time
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTime
The getTime() method returns the number of milliseconds* since the Unix Epoch.
Experiment with them one by one, console log the result, and you should see the difference