up
This commit is contained in:
parent
835d2ae1ce
commit
f3886cfb79
2 changed files with 11 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
|||
Ответ: `1`.
|
||||
The answer: `1`.
|
||||
|
||||
```js
|
||||
//+ run
|
||||
|
@ -9,18 +9,19 @@ while (i) {
|
|||
}
|
||||
```
|
||||
|
||||
Каждое выполнение цикла уменьшает `i`. Проверка `while(i)` даст сигнал "стоп" при `i = 0`.
|
||||
Every loop iteration decreases `i` by `1`. The check `while(i)` stops the loop when `i = 0`.
|
||||
|
||||
Соответственно, шаги цикла:
|
||||
Hence, the steps of the loop make the following sequence ("unrolled"):
|
||||
|
||||
```js
|
||||
var i = 3
|
||||
alert( i-- ); // выведет 3, затем уменьшит i до 2
|
||||
var i = 3;
|
||||
|
||||
alert(i--) // выведет 2, затем уменьшит i до 1
|
||||
alert(i--); // shows 3, decreases i to 2
|
||||
|
||||
alert(i--) // выведет 1, затем уменьшит i до 0
|
||||
alert(i--) // shows 2, decreases i to 1
|
||||
|
||||
// все, проверка while(i) не даст выполняться циклу дальше
|
||||
alert(i--) // shows 1, decreases i to 0
|
||||
|
||||
// done, while(i) check stops the loop
|
||||
```
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
# Последнее значение цикла
|
||||
# Last loop value
|
||||
|
||||
[importance 3]
|
||||
|
||||
Какое последнее значение выведет этот код? Почему?
|
||||
What is be the last value alerted by this code? Why?
|
||||
|
||||
```js
|
||||
var i = 3;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue