diff --git a/1-js/2-first-steps/15-while-for/1-loop-last-value/solution.md b/1-js/2-first-steps/15-while-for/1-loop-last-value/solution.md index 15c634c9..405c162a 100644 --- a/1-js/2-first-steps/15-while-for/1-loop-last-value/solution.md +++ b/1-js/2-first-steps/15-while-for/1-loop-last-value/solution.md @@ -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 ``` diff --git a/1-js/2-first-steps/15-while-for/1-loop-last-value/task.md b/1-js/2-first-steps/15-while-for/1-loop-last-value/task.md index 25359633..3acb1235 100644 --- a/1-js/2-first-steps/15-while-for/1-loop-last-value/task.md +++ b/1-js/2-first-steps/15-while-for/1-loop-last-value/task.md @@ -1,8 +1,8 @@ -# Последнее значение цикла +# Last loop value [importance 3] -Какое последнее значение выведет этот код? Почему? +What is be the last value alerted by this code? Why? ```js var i = 3;