Build a Wordle-Style Game in React
Company: Ramp
Role: Frontend Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Take-home Project
# Build a Wordle-Style Game in React
Build a small Wordle-style game from scratch in React. The secret is a five-letter word, and the player has at most five submitted guesses. Show a five-row board, let the player type only letters, normalize input to uppercase, and color each submitted letter as exact, present in another position, or absent. Display a win or loss state and prevent further submissions when the game ends.
### Constraints & Assumptions
- A guess must contain exactly five letters before it can be submitted.
- Duplicate letters must be scored correctly: a secret letter occurrence can match at most one guessed occurrence.
- The current, unsubmitted guess appears in the next available row without score colors.
- State should have one clear owner and derived values should not be stored redundantly.
### Clarifying Questions to Ask
- Must guesses be validated against a dictionary?
- Should input support the physical keyboard, an on-screen keyboard, or both?
- Are accessibility labels, focus behavior, and reduced motion in scope?
- Should a new-game action choose a new word or replay the same one?
### Solving Hints
Define the game state before defining components. Score exact-position matches before other present-letter matches so duplicate letters do not consume the same secret occurrence twice.
### What a Strong Answer Covers
- Minimal, well-owned React state and clean component boundaries for app, board, row, cell, and input.
- Correct duplicate-letter scoring and immutable state transitions.
- Validation, terminal-state handling, stable keys, and accessible status feedback.
- Tests for scoring, repeated submissions, empty rows, wins, and the final failed guess.
- Awareness of limitations in a quick implementation, such as hard-coded secrets or missing dictionary validation.
### Follow-up Questions
- How would you expose the same score information without relying on color?
- How would you persist and restore a game across page reloads?
- How would you fetch a daily secret without exposing future answers to the client?
Quick Answer: Build a five-guess Wordle-style game in React with clean state ownership and terminal win or loss behavior. Cover duplicate-letter scoring, keyboard input, accessibility, component boundaries, immutable updates, and focused tests.