Workshop › Whack-a-Mole › Step 2 of 18
The field has 3 × 3 holes. We work out where each hole's middle is and keep them all in a list.
```js
const SIZE = 3 // holes per row and per column
const CELL = 120
const TOP = 40 // room for the score and timer
const HOLE_R = 40
const holes = []
for (let row = 0; row < SIZE; row++) {
for (let col = 0; col < SIZE; col++) {
holes.push({ x: col * CELL + CELL / 2, y: TOP + row * CELL + CELL / 2 })
}
}
```holes.Write the constants and the loops under const ctx = ..., after an empty line.
Skills: Loops, Arrays and objects
← A green field Draw the holes →