Workshop › Hangman › Step 24 of 36
You win when every letter of the word has been guessed. Arrays have a method that asks exactly that: every.
```js
function guess(letter) {
// ...
if ([...word].every((l) => guessed.has(l))) {
state = 'won'
} else if (wrong === MAX_WRONG) {
state = 'lost'
}
```[...word].every((l) => guessed.has(l)) runs the test for each letter and is true only if it is true for all.else if means: if we did not win, check whether the misses ran out.In guess, above if (wrong === MAX_WRONG) {, write the every block, joining them with } else. Press Run.
Skills: Game states, Arrays and objects
← Losing Show the word you missed →