Home
← All questions

Memory card matching game | Frontend Machine Coding

MediumPremiumMachine Coding

Asked at Meta · Google · Netflix

Frontend Machine Coding interview practice: Build a flip-and-match memory game with move counter and win detection.

Problem

Build a memory card game (concentration) on a 4×4 grid.

Requirements

  • 8 pairs of cards shuffled face-down; click to flip (max 2 face-up).
  • Matching pair stays open; mismatch flips back after 600ms.
  • Track moves and elapsed time; show win modal when all matched.
  • Disable input while comparing two cards.
  • (Bonus) difficulty levels (4×4, 6×6), restart, best score in localStorage.

Hints / Approach

  • State: cards[{id, symbol, flipped, matched}], first, second, locked.
  • Shuffle with Fisher–Yates; duplicate symbols for pairs.
  • Win: cards.every(c => c.matched).
Premium question

Unlock the in-browser editor, test cases, and model solution with Mentoxis Premium.

Unlock with Premium