Skip to content

Commit c99499e

Browse files
authored
Merge pull request #369 from brentguf/loops
Loops
2 parents 90b1a2b + 0761628 commit c99499e

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

1-js/02-first-steps/12-while-for/article.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ A single execution of the loop body is called *an iteration*. The loop in the ex
3333

3434
If there were no `i++` in the example above, the loop would repeat (in theory) forever. In practice, the browser provides ways to stop such loops, and for server-side JavaScript we can kill the process.
3535

36-
Any expression or a variable can be a loop condition, not just a comparison. They are evaluated and converted to boolean by `while`.
36+
Any expression or a variable can be a loop condition, not just a comparison. They are evaluated and converted to a boolean by `while`.
3737

3838
For instance, the shorter way to write `while (i != 0)` could be `while (i)`:
3939

@@ -227,7 +227,7 @@ while (true) {
227227
alert( 'Sum: ' + sum );
228228
```
229229

230-
The `break` directive is activated in the line `(*)` if the user enters an empty line or cancels the input. It stops the loop immediately, passing the control to the first line after the loop. Namely, `alert`.
230+
The `break` directive is activated at the line `(*)` if the user enters an empty line or cancels the input. It stops the loop immediately, passing the control to the first line after the loop. Namely, `alert`.
231231

232232
The combination "infinite loop + `break` as needed" is great for situations when the condition must be checked not in the beginning/end of the loop, but in the middle, or even in several places of the body.
233233

@@ -266,11 +266,11 @@ for (let i = 0; i < 10; i++) {
266266

267267
From a technical point of view it's identical to the example above. Surely, we can just wrap the code in the `if` block instead of `continue`.
268268

269-
But as a side-effect we got one more figure brackets nesting level. If the code inside `if` is longer than a few lines, that may decrease the overall readability.
269+
But as a side-effect we got one more nesting level (the `alert` call inside the curly braces). If the code inside `if` is longer than a few lines, that may decrease the overall readability.
270270
````
271271
272272
````warn header="No `break/continue` to the right side of '?'"
273-
Please note that syntax constructs that are not expressions cannot be used in `'?'`. In particular, directives `break/continue` are disallowed there.
273+
Please note that syntax constructs that are not expressions cannot be used with the ternary operator `?`. In particular, directives such as `break/continue` are disallowed there.
274274
275275
For example, if we take this code:
276276
@@ -292,7 +292,7 @@ if (i > 5) {
292292
...Then it stops working. The code like this will give a syntax error:
293293
294294
295-
That's just another reason not to use a question mark operator `'?'` instead of `if`.
295+
That's just another reason not to use a question mark operator `?` instead of `if`.
296296
````
297297

298298
## Labels for break/continue
@@ -385,4 +385,4 @@ To make an "infinite" loop, usually the `while(true)` construct is used. Such a
385385

386386
If we don't want to do anything on the current iteration and would like to forward to the next one, the `continue` directive does it.
387387

388-
`Break/continue` support labels before the loop. A label is the only way for `break/continue` to escape the nesting and go to the outer loop.
388+
`break/continue` support labels before the loop. A label is the only way for `break/continue` to escape the nesting and go to the outer loop.

0 commit comments

Comments
 (0)