Prompt
Implement the core timing logic for a reaction-speed game.
Write two functions:
startGame()— returns initial game state { phase: 'wait', score: 0, delay: number } with random 1-5s delayhandleTap(state, now)— processes a tap at timestampnow, returns updated state
Rules:
- Phase 'wait': ignore taps
- Phase 'active': record reaction time (now - targetShown), increment score, transition to 'wait' with new random delay
- Game ends after 10 seconds total (handle in UI)
- Phase 'result': game over, show final score
Live Preview
Game lasts 10 seconds
Score: 0
Wait...
Hints
Solution
Your Code
15 min