Hi, I am new to javascript and trying to teach myself it. I am trying to make a little script that tells a user their reaction time. I want to change the background color of the page, and see how long it takes for them to click down.
I can’t seem to find a suitable way to time this accurately. First, I tried making a setInterval call that would increment a value every ms. However, apparently it is not fast enough to do this, and the values it reports are far too low.
Then I tried calling the date.getTime() function when the background changes color, and comparing it to the time when the user clicks, but both values are exactly the same so it always outputs 0.
Is there a way to accurately time this?