Workshop › Hangman › Step 8 of 36
The letters you have tried go into a Set. masked() then shows a letter if it is in the Set, and _ if not.
```js
let word
let guessed // a Set of the letters tried so far
// The word with the letters not guessed yet hidden: 'C _ S T _ E'.
const masked = () => [...word].map((letter) => (guessed.has(letter) ? letter : '_')).join(' ')
function newWord() {
word = WORDS[Math.floor(Math.random() * WORDS.length)]
guessed = new Set()
}
```let guessed will hold the letters tried so far; new Set() in newWord starts it empty for every word.guessed.has(letter) is true if the letter was tried.condition ? a : b is a short if: a when the condition is true, b otherwise. So a tried letter shows itself,
an untried one shows _.let word write let guessed ....masked, and change its '_' to the ? : form.newWord, under the word = ... line, write guessed = new Set(). Press Run.Skills: Arrays and objects, Game states
← Hide it behind blanks Draw again and again →