Workshop › Wordle-style Word Guess › Step 12 of 26

A secret word

What we are doing

The answer is picked at random from a list of five-letter words each time a game starts.

```js
const WORDS = ['apple', 'beach', 'brain', 'bread', 'brick', 'chair', 'chess', 'clock', 'cloud', 'crane', 'dance', 'dream',
  'drink', 'eagle', 'earth', 'flame', 'fruit', 'ghost', 'glass', 'grape', 'green', 'heart', 'horse', 'house', 'juice',
  'knife', 'laugh', 'lemon', 'light', 'magic', 'money', 'mouse', 'music', 'night', 'ocean', 'paint', 'party', 'piano',
  'pilot', 'plane', 'plant', 'pride', 'queen', 'radio', 'river', 'robot', 'sheep', 'shirt', 'smile', 'snake', 'space',
  'spoon', 'storm', 'sugar', 'table', 'tiger', 'toast', 'train', 'water', 'whale', 'world', 'zebra']

let answer

function reset() {
  answer = WORDS[Math.floor(Math.random() * WORDS.length)]
```

What it means

Your turn

  1. Under const ctx = ... and its empty line, write the WORDS list (you may copy it).
  2. Above let current, write let answer.
  3. In reset, write the answer = ... line at the top. Press Run.

Skills: Arrays and objects

All steps

  1. The canvas and the pen
  2. Paint the background
  3. A function that draws
  4. A row of five tiles
  5. Six rows
  6. Draw again and again
  7. The typed letters
  8. Type with the keyboard
  9. Show the letters
  10. Backspace
  11. Leave shortcuts alone
  12. A secret word
  13. Right letter, right place
  14. Right letter, wrong place
  15. Enter sends the guess
  16. Colour the guesses
  17. Winning and losing
  18. A message line
  19. Where the keys go
  20. Draw the keyboard
  21. Tap a key
  22. Enter and Delete keys
  23. Keys that remember
  24. Keep statistics
  25. Show the statistics
  26. Build it yourself: only real words