your currency



9.1.7 Checkerboard V2 Codehs May 2026

If you’re working through the CodeHS Java (or JavaScript) Graphics track, you’ve probably reached Exercise 9.1.7: Checkerboard V2. This is a classic “level-up” from the basic checkerboard challenge. It’s designed to test your understanding of nested loops, conditional logic, and coordinate math.

In this post, I’ll break down the problem, explain the logic, and provide a clean solution so you can move forward with confidence.

The "V2" autograder on CodeHS is stricter. It may check for: 9.1.7 Checkerboard V2 Codehs

Pro Tip: Run your code with a board size of 4x4 first to verify the pattern before scaling to 8x8.

Expected 4x4 pattern:
R B R B
B R B R
R B R B
B R B R

If you are navigating the CodeHS Java (or JavaScript) curriculum, particularly in the "Advanced Arrays" or "Graphics" sections, you have likely encountered Exercise 9.1.7: Checkerboard V2. If you’re working through the CodeHS Java (or

At first glance, it seems simple: draw a checkerboard. However, this problem is a classic exercise in nested loops, conditional logic, coordinate math, and efficient rendering. It strips away the fluff of game logic and focuses on the core visual structure of an 8x8 grid.

This article will break down the problem, explore the common pitfalls, provide step-by-step solutions in both Java (Console/Graphics) and JavaScript (Web Graphics), and explain the underlying principles so you can truly master the concept. Pro Tip: Run your code with a board


When you run the code, you should see a perfect 8x8 checkerboard with alternating colors, no bleeding, no misalignment, and the first square of row 0 black, row 1 red/white, row 2 black, etc.

Bad Code:

if (row === 0 && col === 0) square.setColor("red");
if (row === 0 && col === 1) square.setColor("black");
// ... 62 more horrendous lines

Fix: Use the (row + col) % 2 formula. Never hardcode each tile.

The goal is typically to draw an 8x8 checkerboard with alternating black and red squares (or another color pair).

We Use Cookies

This website uses cookies to ensure it's basic functionalities and to enhance your online experirience. Chose which categories you allow us to use. Read our cookie policy for details.

Essential cookies

We need these so that you can sign in or use your shopping cart.

Always on

Analytical cookies

These help us understand how poeple use our website and keep improving it.

Marketing cookies

You consent to our use of advertising cookies for profiling, targeting ads, and measuring their impact by enabling these cookies. You also agree to send your data to ad systems for personalized advertising, improving relevance and engagement.

Personalization cookies

We may use these to personalize our site for you.

Cookie preferences saved. Go to Homepage - Browse effects