@@ -21,7 +21,7 @@ while (condition) {
2121
2222While the ` condition ` is ` true ` , the ` code ` from the loop body is executed.
2323
24- For instance, the loop below outputs ` i ` while ` i< 3 ` :
24+ For instance, the loop below outputs ` i ` while ` i < 3 ` :
2525
2626``` js run
2727let i = 0 ;
@@ -37,7 +37,7 @@ If there were no `i++` in the example above, the loop would repeat (in theory) f
3737
3838Any expression or a variable can be a loop condition, not just a comparison. They are evaluated and converted to boolean by ` while ` .
3939
40- For instance, the shorter way to write ` while (i!= 0) ` could be ` while (i) ` :
40+ For instance, the shorter way to write ` while (i != 0) ` could be ` while (i) ` :
4141
4242``` js run
4343let i = 3 ;
@@ -108,8 +108,8 @@ Let's examine the `for` statement part by part:
108108
109109| part | | |
110110| -------| ----------| ----------------------------------------------------------------------------|
111- | begin | ` i= 0 ` | Executes once upon entering the loop. |
112- | condition | ` i< 3 ` | Checked before every loop iteration, if fails the loop stops. |
111+ | begin | ` i = 0 ` | Executes once upon entering the loop. |
112+ | condition | ` i < 3 ` | Checked before every loop iteration, if fails the loop stops. |
113113| step| ` i++ ` | Executes after the body on each iteration, but before the condition check. |
114114| body | ` alert(i) ` | Runs again and again while the condition is truthy |
115115
@@ -192,7 +192,7 @@ for (; i < 3;) {
192192}
193193```
194194
195- The loop became identical to ` while (i< 3) ` .
195+ The loop became identical to ` while (i < 3) ` .
196196
197197We can actually remove everything, thus creating an infinite loop:
198198
@@ -324,7 +324,7 @@ The ordinary `break` after `input` would only break the inner loop. That's not s
324324
325325A * label* is an identifier with a colon before a loop:
326326``` js
327- labelName: for (... ) {
327+ labelName: for (... ) {
328328 ...
329329}
330330```
@@ -369,7 +369,7 @@ For example, it is impossible to do this:
369369```js
370370break label; // jumps to label? No.
371371
372- label: for(...)
372+ label: for (...)
373373```
374374
375375The call to a `break/continue` is only possible from inside the loop, and the label must be somewhere upwards from the directive.
@@ -381,7 +381,7 @@ We covered 3 types of loops:
381381
382382- ` while ` -- The condition is checked before each iteration.
383383- ` do..while ` -- The condition is checked after each iteration.
384- - ` for(;;) ` -- The condition is checked before each iteration, additional settings available.
384+ - ` for (;;) ` -- The condition is checked before each iteration, additional settings available.
385385
386386To make an "infinite" loop, usually the ` while(true) ` construct is used. Such a loop, just like any other, can be stopped with the ` break ` directive.
387387
0 commit comments