Add the text "In addition to the break statement which opts out of th… (#26063)
* Add the text "In addition to the break statement which opts out of the iteration when the condition is false is the continue statement. The `continue` statement skips the condition when the code is true, continues up until the condition is false. Using the above example again, let's see the functionality of the `continue` statement ```javascript for (var elephant = 1; elephant < 10; elephant+=2) { if (elephant === 7) { continue; } console.info('elephant is ' + elephant); } output: elephant is 1 elephant is 3 elephant is 5 elephant is 9 ```" to article * Improved sentence structurepull/25934/head^2
parent
697c040a66
commit
14b29da497
|
@ -79,6 +79,26 @@ elephant is 1
|
|||
elephant is 3
|
||||
elephant is 5
|
||||
```
|
||||
|
||||
In contrast to the `break` statement which opts out of the iteration when the condition is false, the `continue` statement skips the condition when the code is true, and continues up until the condition is false.
|
||||
|
||||
Using the above example again, let's see the functionality of the `continue` statement
|
||||
|
||||
|
||||
```javascript
|
||||
for (var elephant = 1; elephant < 10; elephant+=2) {
|
||||
if (elephant === 7) {
|
||||
continue;
|
||||
}
|
||||
console.info('elephant is ' + elephant);
|
||||
}
|
||||
|
||||
output:
|
||||
elephant is 1
|
||||
elephant is 3
|
||||
elephant is 5
|
||||
elephant is 9
|
||||
```
|
||||
|
||||
### Other Resources
|
||||
* [MDN - for statements](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for)
|
||||
|
|
Loading…
Reference in New Issue