9.1.6 Checkerboard V1 Codehs Jun 2026
In the CodeHS 9.1.6: Checkerboard, v1 exercise, the objective is to create an 8x8 grid where the top three and bottom three rows contain alternating 1s and 0s (representing checker pieces), while the middle two rows consist entirely of 0s. The final result should look like this:
to keep your code flexible. If you change the size of one square, the whole board should adjust automatically. : Create a drawSquare(x, y, color) 9.1.6 checkerboard v1 codehs
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 In the CodeHS 9
Let's test this: