Workshop › Tic-tac-toe › Step 1 of 33
X and O on a 3×3 board. Mouse clicks, a board as an array, finding the winner, and a computer that never loses, thanks to recursion.
The game is drawn on a <canvas>: a 300×300 rectangle of pixels with the id game. We find it from JavaScript
and ask it for its 2D context, the object that holds every drawing command.
```js
const canvas = document.getElementById('game')
const ctx = canvas.getContext('2d')
```document is the page; getElementById('game') finds the element whose id is game.const canvas = gives what was found a name, so later lines can use it.canvas.getContext('2d') asks the canvas for its 2D drawing tools; we call them ctx (short for context).Write the two lines under the three comment lines, then press Run.
Skills: Drawing on a canvas