You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/tutorials/en/variables-and-change.mdx
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -128,10 +128,10 @@ In the template above, you use [`mouseX`](/reference/p5/mouseX) and [`mouseY`](/
128
128
129
129
In [Get Started,](/tutorials/get-started) you learned that strings are [data types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures) that are always surrounded by quotation marks (`""`). To use variables and strings together, we can use [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals) to help us! Template literals begin and end with backticks (`\`\``) instead of quotation marks (`""`). You can type any character in between the backticks to generate a string like in [this example](https://editor.p5js.org/Msqcoding/sketches/pfSJLvxOB). You can include a variable in the string using the `${}` placeholder, and by placing the name of the variable inside the curly brackets like in [this example](https://editor.p5js.org/Msqcoding/sketches/8sM-h5Hd9).
130
130
131
-
Visit [string interpolation](https://www.geeksforgeeks.org/string-interpolation-in-javascript/) (example 2), [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals), or the p5.js reference page for [string](/reference/p5/string) to learn more!
131
+
Visit [string interpolation](https://www.geeksforgeeks.org/string-interpolation-in-javascript/) (example 2), [template literals](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals), or the p5.js reference page for [string](/reference/p5/String) to learn more!
132
132
133
133
<Callouttitle="Note">
134
-
Variables with [numbers](/reference/p5/number) in them can be used as arguments where numbers are required. If a variable that stores a [string](/reference/p5/string) is used where a number should be, the console will show an error message like `“...was expecting Number for the first parameter, received string instead.”` Visit the Error Messages section in the [Field Guide to Debugging](/tutorials/field-guide-to-debugging) for some common errors and how to fix them!
134
+
Variables with [numbers](/reference/p5/number) in them can be used as arguments where numbers are required. If a variable that stores a [string](/reference/p5/String) is used where a number should be, the console will show an error message like `“...was expecting Number for the first parameter, received string instead.”` Visit the Error Messages section in the [Field Guide to Debugging](/tutorials/field-guide-to-debugging) for some common errors and how to fix them!
135
135
</Callout>
136
136
137
137
@@ -276,7 +276,7 @@ In the code above, the cloud is drawn using [`ellipse()`](/reference/p5/ellipse)
276
276
277
277
##### Custom Variables
278
278
279
-
Custom variables store values, like [numbers](/reference/p5/number) or [strings](/reference/p5/string), that can change later. Since custom variables store values that can change, we can use them to change the x- or y-coordinates and size of shapes on the canvas. When the x- or y-coordinate of a shape changes, it appears to be moving. In this step:
279
+
Custom variables store values, like [numbers](/reference/p5/number) or [strings](/reference/p5/String), that can change later. Since custom variables store values that can change, we can use them to change the x- or y-coordinates and size of shapes on the canvas. When the x- or y-coordinate of a shape changes, it appears to be moving. In this step:
280
280
281
281
- you placed a white cloud on the canvas using [`ellipse()`](/reference/p5/ellipse) with the number 50 as an x-coordinate;
282
282
- you *declared* a custom variable named `cloudOneX` before [`setup();`](/reference/p5/setup)
@@ -297,7 +297,7 @@ A *variable’s scope* describes where the variable can be used in a program. It
297
297
298
298
Variables declared inside of other functions (like [`draw()`](/reference/p5/draw) and [`setup()`](/reference/p5/setup)) have *local scope* – which means they can only be used within the block or function where they are declared. Variables declared in [`setup()`](/reference/p5/setup) cannot be used in [`draw()`](/reference/p5/draw) or any other function, and variables defined in [`draw()`](/reference/p5/draw) cannot be used in [`setup()`](/reference/p5/setup). View [this example](https://editor.p5js.org/p5Master718/sketches/aa8bBwGHb) of global and local variable scope.
299
299
300
-
Visit these p5.js reference pages to learn more about declaring, initializing, and using custom variables: [`let`](/reference/p5/let), [numbers](/reference/p5/number), & [strings](/reference/p5/string).
300
+
Visit these p5.js reference pages to learn more about declaring, initializing, and using custom variables: [`let`](/reference/p5/let), [numbers](/reference/p5/number), & [strings](/reference/p5/String).
0 commit comments