Learn by Building Workshop Skills GitHub Türkçe Workshop › Connect Four › Step 8 of 38
Discs in their colors What we are doing Now the drawing reads the board: an empty cell is a dark hole, a cell with 1 or 2 a disc in that player's color. The
colors are kept in an object, COLORS.
```js
const COLORS = { 1: '#ef4444', 2: '#facc15' }
disc(x, y, board[row][col] ? COLORS[board[row][col]] : '#0f172a')
```What it means
COLORS is an object: { key: value, ... }. COLORS[1] reads the value under 1: red.
a ? b : c picks b when a is truthy, otherwise c. 0 counts as false, 1 and 2 as true.
Your turn
Under TOP write COLORS.
In the inner loop of draw, replace '#0f172a' in the disc call with the choice.
Skills: Arrays and objects, Drawing on a canvas
← The board in memory Draw every frame →
All steps A dark background A drawing function The blue board One hole A whole row All 42 holes The board in memory Discs in their colors Draw every frame Where does the disc land? Play a column Taking turns Click to play The next disc Whose turn? Playing with the keyboard Keys 1 to 7 A disc on its way Gravity Watch it fall Inside the board? Walking along a line Four in a row? We have a winner Circle the four Who won? A draw Play again Try a move and take it back Win, or block Don't help the player Prefer the middle The computer's turn Only on your turn You and the computer Counting wins Show the score Build it yourself: the loser starts