FrontendArk

Master Frontend Interviews

  • Practice
  • Playground
  • Resource
Medium

Grid Lights

40 mins

Build a grid of lights in React where clicking on a light activates it, and lights deactivate in the reverse order they were activated.

Requirements:

  1. Display a grid of lights (e.g., 4x4).
  2. Clicking a light toggles it ON (yellow).
  3. Maintain activation order:
    • When all lights are ON and you click another one, the first activated light should turn OFF.
    • In general, lights should deactivate in the reverse order they were activated (like a stack).
  4. Focus on functionality, not styling.

Code Editor

React Component

00:00
Loading...

Live Preview

See your React component