Bootcamp
Search…
7.ICE.4: Guess the Word
Create a game of guess the word.

Setup

Begin with the base react repo.​

Base

Work on the game in the following order:

Part 1

Hardcode a secret word to guess: banana.
Create a controlled form in which the user can only type one letter as a guess.
Create a hard-coded array of letters that represents the word.
Create a state variable. The initial value of this variable is an array which is the same length as the secret word array, but with only _ in the array.
const secretWord = ['b', 'a', 'n', 'a', 'n', 'a'];
​
// the array begins with only _
const [guessedLetters, setGuessedLetters] = useState([
'_',
'_',
'_',
'_',
'_',
'_',
]);
If the user guesses correctly, add the letter to the correctly guessed letters array.
Display the guessed letters' positions on the screen using the array.

Part 2

For each wrong guess the program adds to the figure: (凸 ಠ 益 ಠ)凸
The player can only guess wrong 7 times before the game ends. (the number of characters in the figure)
Note: code only in the App component. No need to make child components of App.

Comfortable

Reset Game

When the user loses create a button on screen that will start a new game.