Workshop › Wordle-style Word Guess › Step 12 of 26
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)]
```WORDS is an array: an ordered list of words in lower case, like the typed letters.WORDS.length is how many there are; Math.random() gives a number from 0 up to 1; times the length, rounded down
with Math.floor, it is a random index.reset picks a new answer for every game.const ctx = ... and its empty line, write the WORDS list (you may copy it).let current, write let answer.reset, write the answer = ... line at the top. Press Run.Skills: Arrays and objects
← Leave shortcuts alone Right letter, right place →