// Fill the current row starting with beeper presence based on row parity function fillRow() // Determine if first cell should have a beeper // For row 1: have beeper, row 2: no beeper, etc. // We check if we are on a beeper to decide pattern var startWithBeeper = beepersPresent();
var size = 8; var S = 40; // pixel square size for (var r = 0; r < size; r++) for (var c = 0; c < size; c++) var x = c * S; var y = r * S; if ((r + c) % 2 === 0) fillRect(x, y, S, S); // filled square else // leave background or draw empty square 9.1.6 checkerboard v1 codehs
Here is the solution code:
, which are the building blocks of game design and UI development. code snippet // Fill the current row starting with beeper
This exercise focuses on using nested loops modulus operator row 2: no beeper
rect.setColor(Color.BLACK);
# Initialize the board board = []