If this is your first time reading about Bounce Coding, I recommend you start from the beginning.
Variables
Variables are a way to store a value as a name. Variables can be used in expressions (essentially another name for an equation) throughout your program. Rather than having to change a value in several locations, we can just use a variable and change it in a single location. We're not actually interested in drawing ellipses, but rather just circles. To enforce this, instead of directly passing numbers to ellipse, let's bind them to variables and ensure that the width and height of the ellipse are equal.
We'll define three variables, centerx, centery and radius to represent the center point and radius of the circle. Instead of changing the arguments to ellipse, try changing the variables we defined.
Things to note
- Since we're passing 2*radius to both the width and height, all we need to do is change the radius variable to adjust the size of the circle.
- In JavaScript, you define a variable using var and it can hold any kind of information. In other languages, you might declare a variable using a type. For example, you might use 'int' to declare a variable that can only hold integer values, or 'string' to hold a a string of text.
- For more on variables, check out Khan Academy's tutorial.