Workshop › Hangman › Step 6 of 36
To check the pick works, we draw the word itself, centered near the bottom. The next step will hide it.
```js
function draw() {
ctx.fillStyle = '#fefce8'
ctx.fillRect(0, 0, canvas.width, canvas.height)
ctx.textAlign = 'center'
ctx.font = 'bold 32px monospace'
ctx.fillStyle = '#1f2937'
ctx.fillText(word, canvas.width / 2, 340)
}
```textAlign = 'center' puts the middle of the text on the given point.font = 'bold 32px monospace': bold, 32 pixels tall, a font where every character is the same width.fillStyle = '#1f2937' is a dark grey for the text.fillText(word, canvas.width / 2, 340) writes word at the middle (480 / 2 = 240), 340 pixels down.Inside draw, under the fillRect line, leave an empty line and write the four text lines. Press Run a few times.
Skills: Drawing on a canvas
← Pick a random word Hide it behind blanks →