JavaScript Graphics

Back to index
Your browser does not support the HTML5 canvas tag. ASSIGNMENT:
You will notice that there are a total of twenty-five red squares in the graphic created using JavaScript displayed to the left. Put another way, this checkerboard pattern is seven squares wide. You will make a similar display which is nine squares wide. This will produce a total of forty-one red squares.

The primary challenge is understanding how the embedded for-loops work and the function of the if statement. Do a series of experiments to unravel the mysterious ways of embedded for-loops. Also see what happens if you remove the if statement. Once you have sufficiently experimented, the way of the embedded for-loop will reveal itself unto you.