#05Memory Card Game
60min

Overview

Create a memory card game where cards are hidden, can be flipped to reveal matches, and track user clicks.

Requirements

  • Display a grid of hidden cards.
  • Shuffle the cards at the start of each new game.
  • Clicking a card reveals its content.
  • If two revealed cards match, keep them visible as matched.
  • If two revealed cards do not match, hide them again after 1 second.
  • Prevent clicking a third card while two non-matching cards are visible.
  • Include a reset button that hides all cards and resets the click counter.
  • Display the total number of clicks in the UI.

Notes

  • Focus on managing the state of each card (hidden, revealed, matched).
  • Think about how to track clicks and update the counter as the user interacts.
  • Handle the timing of hiding non-matching cards carefully to avoid race conditions.
  • Make sure the UI updates correctly when the game is reset.

Tests

  1. renders all cards hidden initially
  2. clicking a card shows it
  3. matching cards remain visible and matched
  4. non-matching cards hide after 1 second
  5. cannot click a third card while two non-matching cards are visible
  6. reset button hides all cards and resets clicks