Skip to content

Commit 42fa0f2

Browse files
Introduce standard 'for' loop in iteration section
Added explanation and syntax for the standard 'for' loop.
1 parent 0dfb715 commit 42fa0f2

File tree

1 file changed

+11
-1
lines changed
  • common-content/en/module/js2/iteration

1 file changed

+11
-1
lines changed

common-content/en/module/js2/iteration/index.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ To solve the sub-goal, we have to repeatedly add each number in the array to the
1616

1717
In programming, we can **iterate** by using a {{<tooltip title="loop">}}A loop is a sequence of instructions that is continually repeated until some condition is reached.{{</tooltip>}}.
1818

19-
In particular, we can use a [`for...of` statement](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) to sum the elements of the array.
19+
### The Standard `for` Loop
20+
21+
Before we look at shortcuts, it is important to understand the **standard `for` loop**. It gives you complete control over how the loop starts, when it stops, and how it moves to the next step.
22+
23+
Here is the syntax:
24+
25+
```js
26+
for (let i = 0; i < 5; i++) {
27+
console.log("Iteration number: " + i);
28+
}
29+
```
2030

2131
```js
2232
function calculateMean(list) {

0 commit comments

Comments
 (0)