A reaction-time test becomes unfair if it measures how long the screen waited before turning green. I built the test as a small state machine: idle, waiting, ready, result, and early. The timer starts only when the ready state begins, so the result represents the click-to-signal interval rather than the random delay.
Random delay prevents anticipation
Starting a round chooses a delay between 1.2 and 4 seconds:
function startWaiting () { phase . value = " waiting " ; const delay = 1200 + Math . random () * 2800 ; clearWait (); waitTimer = setTimeout (() => { phase . value = " ready " ; startTime = performance . now (); }, delay ); }
Enter fullscreen mode
Exit fullscreen mode
The random interval makes memorizing a fixed countdown less useful.…