Wordle looks simple — until you try to color a guess with a repeated letter correctly. That edge case is the whole interview question hiding inside this game. Here's a playable clone in vanilla JS.
🟩 Play it: https://dev48v.infy.uk/game/day18-wordle.html
The two-pass coloring trap
Guess KAYAK, answer APPLE (one A). The naive "is this letter in the word?" colors BOTH A's yellow — wrong. The answer only has one A to give.
Correct algorithm is two passes:
- First pass: mark greens (letter right + position right) and "use up" those answer letters.
- Second pass: for the rest, mark yellow only if an unused copy of that letter remains in the answer — otherwise gray.
Track a per-letter remaining-count so duplicates color exactly right.
The rest
A 6×5 board, the active row captures typing, Enter reveals with a CSS flip, and an on-screen keyboard colors each key by its best-known state (green > yellow > gray). Win on match, reveal the answer on loss.
🔨 Full build (board → input → two-pass scoring → reveal + keyboard → win/lose) on the page: https://dev48v.infy.uk/game/day18-wordle.html
Part of GameFromZero. 🌐 https://dev48v.infy.uk
United States
NORTH AMERICA
Related News
Secret Claude Tracker Shocks Users After Anthropic's Anti-Surveillance Stance
12h ago
EV Batteries Defy Expectations, Last Hundreds of Thousands of Miles
1d ago
GBase 8a Performance Anomaly Case Study: How a Single Parameter Change Sparked a Chain Reaction
1d ago
Who Else Has Inherited a Codebase With Zero Comments and a Prayer?
1d ago
完美的平庸
3h ago