Recall that in our preface section of the code, we declare our canvas:
Then, when we're generating circles in random locations on the canvas, we do this:
The use of "300" in the fillCircle obviously corresponds to the "300" when the canvas is created. Makes perfect sense.
But what if weeks later we chose to make the canvas a different size - say 400 x 500. We'd need to make the change in two different places.
For this reason, it's much better style to do something like this:
Remember, "myCanvas" is just a name I made up at the very beginning, but I need to be consistent in using it, otherwise it would be like if your teacher suddenly started calling your classmates by completely different names each day.
|