Workshop › Connect Four › Step 10 of 38
In this game you choose only a column; the disc falls to the lowest empty hole. dropRow(col) finds it: it looks
from the bottom row upwards and stops at the first empty cell. If there is none, it returns -1.
```js
// The lowest empty row in a column, or -1 when the column is full.
function dropRow(col) {
for (let row = ROWS - 1; row >= 0; row--) {
if (board[row][col] === 0) return row
}
return -1
}
```=== asks "is it equal?". At the first empty cell, return row gives that row back and leaves the function.return -1.Under reset, after an empty line, write the comment and dropRow.
Skills: Loops, Functions
← Draw every frame Play a column →