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: 1-js/02-first-steps/12-while-for/article.md
+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
@@ -142,7 +142,7 @@ if (i < 3) { alert(i); i++ }
142
142
```
143
143
144
144
````smart header="Inline variable declaration"
145
-
Here the "counter" variable `i` is declared right in the loop. That's called an "inline" variable declaration. Such variable is visible only inside the loop.
145
+
Here the "counter" variable `i` is declared right in the loop. That's called an "inline" variable declaration. Such variables are visible only inside the loop.
146
146
147
147
```js run
148
148
for (*!*let*/!* i = 0; i < 3; i++) {
@@ -202,15 +202,15 @@ for (;;) {
202
202
}
203
203
```
204
204
205
-
Please note that the two `for` semicolons `;` must present, otherwise it would be a syntax error.
205
+
Please note that the two `for` semicolons `;` must be present, otherwise it would be a syntax error.
206
206
207
207
## Breaking the loop
208
208
209
209
Normally the loop exits when the condition becomes falsy.
210
210
211
211
But we can force the exit at any moment. There's a special `break` directive for that.
212
212
213
-
For example, this code below asks user for numbers and breaks if no number entered:
213
+
For example, the loop below asks the user for a series of numbers, but "breaks" when no number is entered:
214
214
215
215
```js
216
216
let sum =0;
@@ -353,7 +353,7 @@ In the code above `break outer` looks upwards for the label named `outer` and br
353
353
354
354
So the control goes straight from `(*)` to `alert('Done!')`.
355
355
356
-
We can also move a label into the separate string:
0 commit comments