All questions

Wordle

Premium

Wordle

Build Wordle: guess a 5-letter word in six tries, with per-letter color feedback after each guess — green for the right letter in the right spot, yellow for a letter that's in the word but misplaced, grey for absent. The subtle part is the coloring algorithm: it must handle duplicate letters correctly, which takes two passes.

Signature

type Score = 'correct' | 'present' | 'absent';
function scoreGuess(guess: string, answer: string): Score[];

// A self-contained component. No props.
function App(): JSX.Element;

Examples

answer = REACT, guess = TRACE →
  T present · R present · A correct · C present · E present
answer = REACT, guess = EERIE →
  only ONE E is colored (answer has one E); the extra E's are absent

Notes

  • Two-pass scoring. First pass marks exact matches and consumes those letters; second pass marks present from what's left.
  • Duplicate handling. Track remaining letter counts so a guess can't "use" a letter more times than it appears.
  • Keyboard input. Letters append to the current row; Backspace deletes; Enter submits a full 5-letter row.
  • Six guesses. Win on an exact match; after six wrong guesses, reveal the answer.

Unlock the solution & editor

  • Runnable editor + tests

    Solve in the browser with instant Jest feedback.

  • Detailed solutions

    Walkthroughs, edge cases, and complexity notes.

  • Multi-framework variants

    React, Vue, Vanilla, Angular — same question, different stacks.

Upgrade to Premium