Skip to content

Commit 5e82f3b

Browse files
committed
docs: replace loop length with segments and declare move in repeating-with-loops tutorial
1 parent bd17e18 commit 5e82f3b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/content/tutorials/en/repeating-with-loops.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ Above `setup()`:
199199
In `draw()`:
200200

201201
- After the code that draws the finish line, declare a new local variable `x` to position all the body segments: `let x = circX;`
202-
- Add a *for loop* using: `for (let i = 0; i < length; i += 1) { }`
202+
- Add a *for loop* using: `for (let i = 0; i < segments; i += 1) { }`
203203
- A *for loop* will repeat the code we write inside the curly brackets multiple times. 
204204
- Move the lines of code that draw the `circle()` into the curly brackets of the *for loop*.
205205
- After the for loop, add: `circX += spacing` 
@@ -936,7 +936,7 @@ function moveCaterpillars() {
936936
  for (let i = 0; i < numCaterpillars; i += 1) {
937937
    //Give each caterpillar a
938938
    //random speed.
939-
    move = random(5, 30);
939+
    let move = random(5, 30);
940940
    caterpillarEnds[i] += move;
941941
}
942942
}
@@ -1001,7 +1001,7 @@ function moveCaterpillars() {
10011001
  for (let i = 0; i < numCaterpillars; i += 1) {
10021002
    //Give each caterpillar a
10031003
    //random speed.
1004-
    move = random(5, 30);
1004+
    let move = random(5, 30);
10051005
10061006
    // Update caterpillars' x-coordinates
10071007
    caterpillarEnds[i] += move;

0 commit comments

Comments
 (0)