Add nullish coalescing to multiple articles, refactor operators, renumber the chapter

This commit is contained in:
Ilya Kantor 2020-05-02 17:37:12 +03:00
parent 175aefa0b8
commit 8a13c992d6
54 changed files with 386 additions and 183 deletions

View file

@ -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
```

View file

@ -0,0 +1,15 @@
importance: 3
---
# Last loop value
What is the last value alerted by this code? Why?
```js
let i = 3;
while (i) {
alert( i-- );
}
```