mediumReact Native#136

Reaction Game (Juego de Reflejos)

Prompt

Implement the core timing logic for a reaction-speed game.

Write two functions:

  1. startGame() — returns initial game state { phase: 'wait', score: 0, delay: number } with random 1-5s delay
  2. handleTap(state, now) — processes a tap at timestamp now, 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

Tests

Click Run to test your code