Task
Implement a simplified Wordle-style game as a small React app. No styling/CSS is required (plain HTML output is fine).
Game rules (assume Wordle-like defaults)
-
The secret word is a fixed
5-letter
English word (you may hardcode it, or pass it in as a prop).
-
The player has at most
6 attempts
to guess the word.
-
Each guess must be exactly
5 letters
(A–Z). Reject/ignore invalid submissions.
-
After each submitted guess, show per-letter feedback:
-
Correct
: the letter is in the correct position.
-
Present
: the letter exists in the secret word but in a different position.
-
Absent
: the letter does not exist in the secret word.
-
Letter matching should handle duplicates correctly (e.g., if the secret has one
A
, only one
A
in the guess can be marked as Correct/Present).
UI/Interaction requirements
-
Allow the user to type a guess (e.g., an input box) and submit (e.g., Enter key or a button).
-
Display the history of guesses, each with its feedback (text labels are fine, e.g.,
C/P/A
per character).
-
End state:
-
If the user guesses the secret word, show a “You win” message and stop accepting further guesses.
-
If the user uses all attempts without guessing correctly, show a “Game over” message and reveal the secret word.
Clarifications
-
You may assume a single round (no need for restart unless you want to add it).
-
No backend is required.
-
No external UI libraries required.
Example
Secret: CRANE
Guess: CANDY
Feedback (conceptually): C=Correct, A=Present, N=Present, D=Absent, Y=Absent