Workshop › Hangman › Step 4 of 36
The picture will change after every guess, so it will be drawn again and again. We put the drawing lines in a
function named draw; one call, draw(), repaints everything.
```js
function draw() {
ctx.fillStyle = '#fefce8'
ctx.fillRect(0, 0, canvas.width, canvas.height)
}
draw()
```function draw() { ... } defines the recipe; it does not run yet.{ and } are its body, indented by two spaces.draw() with parentheses runs it.Wrap the two drawing lines in function draw() { ... } (indented by two spaces) and call draw() after it.
Skills: Functions
← Paint the paper Pick a random word →