Workshop › Tic-tac-toe › Step 11 of 33
X is pink and O is blue. The color now depends on the mark, so it moves inside the loop and is picked with a short
question: condition ? yes : no.
```js
board.forEach((mark, index) => {
if (mark === '') return
ctx.fillStyle = mark === 'X' ? '#f38ba8' : '#89b4fa'
```mark === 'X' ? '#f38ba8' : '#89b4fa' means: if mark is X, pink, otherwise blue.ctx.fillStyle = '#f38ba8' above the loop is deleted: every mark now picks its own color.ctx.fillStyle = '#f38ba8' above board.forEach.if (mark === '') return, write the new fillStyle line. Press Run.Skills: Drawing on a canvas
← Draw what the board holds Make a move →