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,17 @@
|
|||
**The answer: from `0` to `4` in both cases.**
|
||||
|
||||
```js run
|
||||
for (let i = 0; i < 5; ++i) alert( i );
|
||||
|
||||
for (let i = 0; i < 5; i++) alert( i );
|
||||
```
|
||||
|
||||
That can be easily deducted from the algorithm of `for`:
|
||||
|
||||
1. Execute once `i = 0` before everything (begin).
|
||||
2. Check the condition `i < 5`
|
||||
3. If `true` -- execute the loop body `alert(i)`, and then `i++`
|
||||
|
||||
The increment `i++` is separated from the condition check (2). That's just another statement.
|
||||
|
||||
The value returned by the increment is not used here, so there's no difference between `i++` and `++i`.
|
20
1-js/02-first-steps/13-while-for/3-which-value-for/task.md
Normal file
20
1-js/02-first-steps/13-while-for/3-which-value-for/task.md
Normal file
|
@ -0,0 +1,20 @@
|
|||
importance: 4
|
||||
|
||||
---
|
||||
|
||||
# Which values get shown by the "for" loop?
|
||||
|
||||
For each loop write down which values it is going to show. Then compare with the answer.
|
||||
|
||||
Both loops `alert` same values or not?
|
||||
|
||||
1. The postfix form:
|
||||
|
||||
```js
|
||||
for (let i = 0; i < 5; i++) alert( i );
|
||||
```
|
||||
2. The prefix form:
|
||||
|
||||
```js
|
||||
for (let i = 0; i < 5; ++i) alert( i );
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue