The goal is to generate an 8x8 grid where elements alternate. In computer science, this is a classic application of the . Grid Structure: A list of lists (8 rows, 8 columns).
function start() var boardSize = 8; var squareSize = 50; var colors = ["red", "black"]; for(var i = 0; i < boardSize; i++) for(var j = 0; j < boardSize; j++) var square = new Rectangle(squareSize, squareSize); square.setPosition(j * squareSize, i * squareSize); square.setColor(colors[(i + j) % 2]); add(square);