Add nullish coalescing to multiple articles, refactor operators, renumber the chapter
This commit is contained in:
parent
175aefa0b8
commit
8a13c992d6
54 changed files with 386 additions and 183 deletions
|
@ -0,0 +1,25 @@
|
|||
The answer: `1`.
|
||||
|
||||
```js run
|
||||
let i = 3;
|
||||
|
||||
while (i) {
|
||||
alert( i-- );
|
||||
}
|
||||
```
|
||||
|
||||
Every loop iteration decreases `i` by `1`. The check `while(i)` stops the loop when `i = 0`.
|
||||
|
||||
Hence, the steps of the loop form the following sequence ("loop unrolled"):
|
||||
|
||||
```js
|
||||
let i = 3;
|
||||
|
||||
alert(i--); // shows 3, decreases i to 2
|
||||
|
||||
alert(i--) // shows 2, decreases i to 1
|
||||
|
||||
alert(i--) // shows 1, decreases i to 0
|
||||
|
||||
// done, while(i) check stops the loop
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue