pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/javascript-tutorial/uk.javascript.info/pull/78.patch

ƒΠΌΠΎΠ²Π° β†’ Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ Ρ‚Ρ–Π»ΠΎ Ρ– Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ ΠΊΡ€ΠΎΠΊ if (i < 3) { alert(i); i++ } -// ...finish, because now i == 3 +// ...ΠΊΡ–Π½Π΅Ρ†ΡŒ, Ρ‚ΠΎΠΌΡƒ Ρ‰ΠΎ Π·Π°Ρ€Π°Π· i == 3 ``` ````smart header="Inline variable declaration" From 7131a74b3566bda333c88d7c21c1b4a4547b6d5a Mon Sep 17 00:00:00 2001 From: tarasyyyk Date: Thu, 12 Mar 2020 23:10:48 +0200 Subject: [PATCH 2/7] Translate 'Skipping parts' --- 1-js/02-first-steps/12-while-for/article.md | 55 +++++++++++---------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/1-js/02-first-steps/12-while-for/article.md b/1-js/02-first-steps/12-while-for/article.md index 987e57868..685509081 100644 --- a/1-js/02-first-steps/12-while-for/article.md +++ b/1-js/02-first-steps/12-while-for/article.md @@ -112,76 +112,77 @@ for (let i = 0; i < 3; i++) { // ΠΏΠΎΠΊΠ°Π·ΡƒΡ”Ρ‚ΡŒΡΡ 0, Π΄Π°Π»Ρ– 1, ΠΏΠΎΡ‚Ρ– | ΠΊΡ€ΠΎΠΊ| `i++` | Π’ΠΈΠΊΠΎΠ½ΡƒΡ”Ρ‚ΡŒΡΡ після Ρ‚Ρ–Π»Π° Π½Π° ΠΊΠΎΠΆΠ½Ρ–ΠΉ Ρ–Ρ‚Π΅Ρ€Π°Ρ†Ρ–Ρ—, Π°Π»Π΅ ΠΏΠ΅Ρ€Π΅Π΄ ΠΏΠ΅Ρ€Π΅Π²Ρ–Ρ€ΠΊΠΎΡŽ ΡƒΠΌΠΎΠ²ΠΈ. | Π—Π°Π³Π°Π»ΡŒΠ½ΠΈΠΉ Π°Π»Π³ΠΎΡ€ΠΈΡ‚ΠΌ Ρ†ΠΈΠΊΠ»Ρƒ ΠΏΡ€Π°Ρ†ΡŽΡ” Ρ‚Π°ΠΊ: + ``` -ΠŸΠΎΡ‡Π°Ρ‚ΠΎΠΊ виконання -β†’ (if ΡƒΠΌΠΎΠ²Π° β†’ Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ Ρ‚Ρ–Π»ΠΎ Ρ– Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ ΠΊΡ€ΠΎΠΊ) -β†’ (if ΡƒΠΌΠΎΠ²Π° β†’ Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ Ρ‚Ρ–Π»ΠΎ Ρ– Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ ΠΊΡ€ΠΎΠΊ) -β†’ (if ΡƒΠΌΠΎΠ²Π° β†’ Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ Ρ‚Ρ–Π»ΠΎ Ρ– Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ ΠΊΡ€ΠΎΠΊ) +*ΠŸΠΎΡ‡Π°Ρ‚ΠΎΠΊ* виконання +β†’ (Π―ΠΊΡ‰ΠΎ *ΡƒΠΌΠΎΠ²Π°* == true β†’ Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ Ρ‚Ρ–Π»ΠΎ Ρ– Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ ΠΊΡ€ΠΎΠΊ) +β†’ (Π―ΠΊΡ‰ΠΎ *ΡƒΠΌΠΎΠ²Π°* == true β†’ Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ Ρ‚Ρ–Π»ΠΎ Ρ– Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ ΠΊΡ€ΠΎΠΊ) +β†’ (Π―ΠΊΡ‰ΠΎ *ΡƒΠΌΠΎΠ²Π°* == true β†’ Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ Ρ‚Ρ–Π»ΠΎ Ρ– Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ ΠΊΡ€ΠΎΠΊ) β†’ ... ``` -That is, `begin` executes once, and then it iterates: after each `condition` test, `body` and `step` are executed. +Π‘ΠΏΠΎΡ‡Π°Ρ‚ΠΊΡƒ ΠΎΠ΄ΠΈΠ½ Ρ€Π°Π· Π²ΠΈΠΊΠΎΠ½ΡƒΡ”Ρ‚ΡŒΡΡ `ΠΏΠΎΡ‡Π°Ρ‚ΠΎΠΊ`, ΠΏΠΎΡ‚Ρ–ΠΌ ΠΏΡ€ΠΈ ΠΊΠΎΠΆΠ½Ρ–ΠΉ Ρ–Ρ‚Π΅Ρ€Π°Ρ†Ρ–Ρ—: ΠΏΠ΅Ρ€Π΅Π²Ρ–Ρ€ΡΡ”Ρ‚ΡŒΡΡ `ΡƒΠΌΠΎΠ²Π°`, Π²ΠΈΠΊΠΎΠ½ΡƒΡ”Ρ‚ΡŒΡΡ `Ρ‚Ρ–Π»ΠΎ` Ρ†ΠΈΠΊΠ»Ρƒ Ρ‚Π° `ΠΊΡ€ΠΎΠΊ`. -If you are new to loops, it could help to go back to the example and reproduce how it runs step-by-step on a piece of paper. +Π―ΠΊΡ‰ΠΎ Π²ΠΈ Π½ΠΎΠ²Π°Ρ‡ΠΎΠΊ Ρƒ Ρ†ΠΈΠΊΠ»Π°Ρ…, Π²Π°ΠΌ ΠΌΠΎΠΆΠ΅ Π΄ΠΎΠΏΠΎΠΌΠΎΠ³Ρ‚ΠΈ ΠΏΠΎΠΊΡ€ΠΎΠΊΠΎΠ²Π΅ виконання Ρ†ΡŒΠΎΠ³ΠΎ ΠΏΡ€ΠΈΠΊΠ»Π°Π΄Ρƒ Π½Π° Π°Ρ€ΠΊΡƒΡˆΡ– ΠΏΠ°ΠΏΠ΅Ρ€Ρƒ. -Ось Ρ‰ΠΎ Π²Ρ–Π΄Π±ΡƒΠ²Π°Ρ”Ρ‚ΡŒΡΡ Ρƒ Π½Π°ΡˆΠΎΠΌΡƒ Π²ΠΈΠΏΠ°Π΄ΠΊΡƒ: +Ось Ρ‰ΠΎ Π²Ρ–Π΄Π±ΡƒΠ²Π°Ρ”Ρ‚ΡŒΡΡ Π² Π½Π°ΡˆΠΎΠΌΡƒ Π²ΠΈΠΏΠ°Π΄ΠΊΡƒ: ```js // for (let i = 0; i < 3; i++) alert(i) // ΠŸΠΎΡ‡Π°Ρ‚ΠΎΠΊ виконання let i = 0 -// if ΡƒΠΌΠΎΠ²Π° β†’ Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ Ρ‚Ρ–Π»ΠΎ Ρ– Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ ΠΊΡ€ΠΎΠΊ +// Π―ΠΊΡ‰ΠΎ ΡƒΠΌΠΎΠ²Π° == true β†’ Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ Ρ‚Ρ–Π»ΠΎ Ρ– Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ ΠΊΡ€ΠΎΠΊ if (i < 3) { alert(i); i++ } -// if ΡƒΠΌΠΎΠ²Π° β†’ Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ Ρ‚Ρ–Π»ΠΎ Ρ– Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ ΠΊΡ€ΠΎΠΊ +// Π―ΠΊΡ‰ΠΎ ΡƒΠΌΠΎΠ²Π° == true β†’ Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ Ρ‚Ρ–Π»ΠΎ Ρ– Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ ΠΊΡ€ΠΎΠΊ if (i < 3) { alert(i); i++ } -// if ΡƒΠΌΠΎΠ²Π° β†’ Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ Ρ‚Ρ–Π»ΠΎ Ρ– Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ ΠΊΡ€ΠΎΠΊ +// Π―ΠΊΡ‰ΠΎ ΡƒΠΌΠΎΠ²Π° == true β†’ Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ Ρ‚Ρ–Π»ΠΎ Ρ– Π²ΠΈΠΊΠΎΠ½Π°Ρ‚ΠΈ ΠΊΡ€ΠΎΠΊ if (i < 3) { alert(i); i++ } // ...ΠΊΡ–Π½Π΅Ρ†ΡŒ, Ρ‚ΠΎΠΌΡƒ Ρ‰ΠΎ Π·Π°Ρ€Π°Π· i == 3 ``` -````smart header="Inline variable declaration" -Here, the "counter" variable `i` is declared right in the loop. This is called an "inline" variable declaration. Such variables are visible only inside the loop. +````smart header="Π’Π±ΡƒΠ΄ΠΎΠ²Π°Π½Π΅ оголошСння Π·ΠΌΡ–Π½Π½ΠΎΡ—" +Π’ Ρ†ΡŒΠΎΠΌΡƒ ΠΏΡ€ΠΈΠΊΠ»Π°Π΄Ρ– всСрСдині Ρ†ΠΈΠΊΠ»Ρƒ оголошСна Π·ΠΌΡ–Π½Π½Π° `i`, яка Π²ΠΈΠΊΠΎΠ½ΡƒΡ” Ρ„ΡƒΠ½ΠΊΡ†Ρ–ΡŽ Π»Ρ–Ρ‡ΠΈΠ»ΡŒΠ½ΠΈΠΊΠ°. Π¦Π΅ Ρ‚Π°ΠΊ Π·Π²Π°Π½Π΅ Β«Π²Π±ΡƒΠ΄ΠΎΠ²Π°Π½Π΅Β» оголошСння Π·ΠΌΡ–Π½Π½ΠΎΡ—. Π’Π°ΠΊΡ– Π·ΠΌΡ–Π½Π½Ρ– доступні лишС всСрСдині Ρ†ΠΈΠΊΠ»Ρƒ. ```js run for (*!*let*/!* i = 0; i < 3; i++) { alert(i); // 0, 1, 2 } -alert(i); // error, no such variable +alert(i); // ΠΏΠΎΠΌΠΈΠ»ΠΊΠ°, Π½Π΅ΠΌΠ°Ρ” Ρ‚Π°ΠΊΠΎΡ— Π·ΠΌΡ–Π½Π½ΠΎΡ— ``` -Instead of defining a variable, we could use an existing one: +Π—Π°ΠΌΡ–ΡΡ‚ΡŒ оголошСння Π½ΠΎΠ²ΠΎΡ— Π·ΠΌΡ–Π½Π½ΠΎΡ—, ΠΌΠΈ ΠΌΠΎΠΆΠ΅ΠΌΠΎ використовувати Ρ–ΡΠ½ΡƒΡŽΡ‡Ρƒ: ```js run let i = 0; -for (i = 0; i < 3; i++) { // use an existing variable +for (i = 0; i < 3; i++) { // використовуємо Ρ–ΡΠ½ΡƒΡŽΡ‡Ρƒ Π·ΠΌΡ–Π½Π½Ρƒ alert(i); // 0, 1, 2 } -alert(i); // 3, visible, because declared outside of the loop +alert(i); // 3, Π·ΠΌΡ–Π½Π½Π° доступна, Ρ‚ΠΎΠΌΡƒ Ρ‰ΠΎ Π²ΠΎΠ½Π° оголошСна ΠΏΠΎΠ·Π° Ρ†ΠΈΠΊΠ»ΠΎΠΌ ``` ```` -### Skipping parts +### ΠŸΡ€ΠΎΠΏΡƒΡΠΊ частин Π² "for" -Any part of `for` can be skipped. +Π‘ΡƒΠ΄ΡŒ-яку частину `for` ΠΌΠΎΠΆΠ½Π° пропустити. -For example, we can omit `begin` if we don't need to do anything at the loop start. +Наприклад, ΠΌΠΈ ΠΌΠΎΠΆΠ΅ΠΌΠΎ опустити `ΠΏΠΎΡ‡Π°Ρ‚ΠΎΠΊ`, якщо Π½Π°ΠΌ Π½Π΅ ΠΏΠΎΡ‚Ρ€Ρ–Π±Π½ΠΎ Π½Ρ–Ρ‡ΠΎΠ³ΠΎ Ρ€ΠΎΠ±ΠΈΡ‚ΠΈ ΠΏΠ΅Ρ€Π΅Π΄ стартом Ρ†ΠΈΠΊΠ»Ρƒ. -Like here: +Ось Ρ‚Π°ΠΊ: ```js run -let i = 0; // we have i already declared and assigned +let i = 0; // ΠΌΠΈ Π²ΠΆΠ΅ ΠΌΠ°Ρ”ΠΌΠΎ ΠΎΠ³ΠΎΠ»ΠΎΡˆΠ΅Π½Ρƒ Π·ΠΌΡ–Π½Π½Ρƒ Ρ– присвоєнС значСння -for (; i < 3; i++) { // no need for "begin" +for (; i < 3; i++) { // Π½Π΅ΠΌΠ°Ρ” нСобхідності Π² "ΠΏΠΎΡ‡Π°Ρ‚ΠΊΡƒ" alert( i ); // 0, 1, 2 } ``` -We can also remove the `step` part: +Ми Ρ‚Π°ΠΊΠΎΠΆ ΠΌΠΎΠΆΠ΅ΠΌΠΎ Π²ΠΈΠ΄Π°Π»ΠΈΡ‚ΠΈ частину `ΠΊΡ€ΠΎΠΊ`: ```js run let i = 0; @@ -191,17 +192,17 @@ for (; i < 3;) { } ``` -This makes the loop identical to `while (i < 3)`. +Π¦Π΅ Ρ€ΠΎΠ±ΠΈΡ‚ΡŒ Ρ†ΠΈΠΊΠ» Ρ–Π΄Π΅Π½Ρ‚ΠΈΡ‡Π½ΠΈΠΌ Π΄ΠΎ `while (i < 3)`. -We can actually remove everything, creating an infinite loop: +МоТна Π²Π·Π°Π³Π°Π»Ρ– Π·Π°Π±Ρ€Π°Ρ‚ΠΈ всС, ΠΎΡ‚Ρ€ΠΈΠΌΠ°Π²ΡˆΠΈ нСскінчСнний Ρ†ΠΈΠΊΠ»: ```js for (;;) { - // repeats without limits + // Π±ΡƒΠ΄Π΅ Π²Ρ–Ρ‡Π½ΠΎ ΠΏΠΎΠ²Ρ‚ΠΎΡ€ΡŽΠ²Π°Ρ‚ΠΈΡΡ } ``` -Please note that the two `for` semicolons `;` must be present. Otherwise, there would be a syntax error. +Π—Π°ΡƒΠ²Π°ΠΆΡ‚Π΅, Ρ‰ΠΎ Ρ†Ρ– Π΄Π²ΠΎΠΊΡ€Π°ΠΏΠΊΠΈ `;` ΠΏΠΎΠ²ΠΈΠ½Π½Ρ– Π±ΡƒΡ‚ΠΈ, Ρ–Π½Π°ΠΊΡˆΠ΅ Π²ΠΈΠ½ΠΈΠΊΠ½Π΅ синтаксична ΠΏΠΎΠΌΠΈΠ»ΠΊΠ°. ## Breaking the loop From 67a3a633341b2342a2fa6a3f72f50a4bdff8c931 Mon Sep 17 00:00:00 2001 From: tarasyyyk Date: Sun, 15 Mar 2020 14:40:42 +0200 Subject: [PATCH 3/7] Translate 'Breaking the loop' --- 1-js/02-first-steps/12-while-for/article.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/1-js/02-first-steps/12-while-for/article.md b/1-js/02-first-steps/12-while-for/article.md index 685509081..c59fed0a5 100644 --- a/1-js/02-first-steps/12-while-for/article.md +++ b/1-js/02-first-steps/12-while-for/article.md @@ -204,20 +204,20 @@ for (;;) { Π—Π°ΡƒΠ²Π°ΠΆΡ‚Π΅, Ρ‰ΠΎ Ρ†Ρ– Π΄Π²ΠΎΠΊΡ€Π°ΠΏΠΊΠΈ `;` ΠΏΠΎΠ²ΠΈΠ½Π½Ρ– Π±ΡƒΡ‚ΠΈ, Ρ–Π½Π°ΠΊΡˆΠ΅ Π²ΠΈΠ½ΠΈΠΊΠ½Π΅ синтаксична ΠΏΠΎΠΌΠΈΠ»ΠΊΠ°. -## Breaking the loop +## ΠŸΠ΅Ρ€Π΅Ρ€ΠΈΠ²Π°Π½Π½Ρ Ρ†ΠΈΠΊΠ»Ρƒ: "break" -Normally, a loop exits when its condition becomes falsy. +Π—Π°Π·Π²ΠΈΡ‡Π°ΠΉ, Ρ†ΠΈΠΊΠ» Π·Π°Π²Π΅Ρ€ΡˆΡƒΡ”Ρ‚ΡŒΡΡ, ΠΊΠΎΠ»ΠΈ ΡƒΠΌΠΎΠ²Π° стає `false`. -But we can force the exit at any time using the special `break` directive. +АлС ΠΌΠΈ ΠΌΠΎΠΆΠ΅ΠΌΠΎ Π² Π±ΡƒΠ΄ΡŒ-який ΠΌΠΎΠΌΠ΅Π½Ρ‚ Π²ΠΈΠΉΡ‚ΠΈ Π· Ρ†ΠΈΠΊΠ»Ρƒ, Π²ΠΈΠΊΠΎΡ€ΠΈΡΡ‚Π°Π²ΡˆΠΈ ΡΠΏΠ΅Ρ†Ρ–Π°Π»ΡŒΠ½Ρƒ Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²Ρƒ `break`. -For example, the loop below asks the user for a series of numbers, "breaking" when no number is entered: +Наприклад, наступний ΠΊΠΎΠ΄ Π·Π°ΠΏΠΈΡ‚ΡƒΡ” Π² користувача число Π΄ΠΎ Ρ‚ΠΈΡ… ΠΏΡ–Ρ€, ΠΏΠΎΠΊΠΈ користувач Ρ—Ρ… Π²Π²ΠΎΠ΄ΠΈΡ‚ΡŒ. ΠŸΡ–ΡΠ»Ρ Ρ‚ΠΎΠ³ΠΎ, як користувач Π½Π΅ Π²Π²Ρ–Π² число β€” Ρ†ΠΈΠΊΠ» Π·Π°Π²Π΅Ρ€ΡˆΡƒΡ”Ρ‚ΡŒΡΡ (Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²ΠΎΡŽ "break") Ρ– Π²ΠΈΠ²ΠΎΠ΄ΠΈΡ‚ΡŒ суму чисСл: ```js run let sum = 0; while (true) { - let value = +prompt("Enter a number", ''); + let value = +prompt("Π’Π²Π΅Π΄Ρ–Ρ‚ΡŒ число", ''); *!* if (!value) break; // (*) @@ -226,12 +226,12 @@ while (true) { sum += value; } -alert( 'Sum: ' + sum ); +alert( 'Π‘ΡƒΠΌΠ°: ' + sum ); ``` -The `break` directive is activated at the line `(*)` if the user enters an empty line or cancels the input. It stops the loop immediately, passing control to the first line after the loop. Namely, `alert`. +Π”ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²Π° `break` Π² рядку `(*)` ΡΠΏΡ€Π°Ρ†ΡŒΠΎΠ²ΡƒΡ” Ρ‚ΠΎΠ΄Ρ–, ΠΊΠΎΠ»ΠΈ користувач Π²Π²ΠΎΠ΄ΠΈΡ‚ΡŒ ΠΏΠΎΡ€ΠΎΠΆΠ½Ρ–ΠΉ рядок Π°Π±ΠΎ скасовує ввСдСння. Ця Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²Π° Π½Π΅Π³Π°ΠΉΠ½ΠΎ Π·Π°Π²Π΅Ρ€ΡˆΡƒΡ” виконання Ρ†ΠΈΠΊΠ»Ρƒ Ρ– ΠΏΠ΅Ρ€Π΅Π΄Π°Ρ” ΠΊΠΎΠ½Ρ‚Ρ€ΠΎΠ»ΡŒ наступному рядку Π·Π° Ρ†ΠΈΠΊΠ»ΠΎΠΌ, Ρ‚ΠΎΠ±Ρ‚ΠΎ Π½Π° `alert`. -The combination "infinite loop + `break` as needed" is great for situations when a loop's condition must be checked not in the beginning or end of the loop, but in the middle or even in several places of its body. +ΠšΠΎΠΌΠ±Ρ–Π½Π°Ρ†Ρ–Ρ «нСскінчСнний Ρ†ΠΈΠΊΠ» + `break`Β» β€” Ρ‡ΡƒΠ΄ΠΎΠ²Π° Ρ€Ρ–Ρ‡ для Ρ‚ΠΈΡ… ситуацій, ΠΊΠΎΠ»ΠΈ ΡƒΠΌΠΎΠ²Π° для пСрСривання Π·Π½Π°Ρ…ΠΎΠ΄ΠΈΡ‚ΡŒΡΡ Π½Π΅ Π½Π° ΠΏΠΎΡ‡Π°Ρ‚ΠΊΡƒ Π°Π±ΠΎ ΠΊΡ–Π½Ρ†Ρ– Ρ†ΠΈΠΊΠ»Ρƒ, Π° всСрСдині (Π°Π±ΠΎ Π½Π°Π²Ρ–Ρ‚ΡŒ Π² Π΄Π΅ΠΊΡ–Π»ΡŒΠΊΠΎΡ… місцях) Ρ‚Ρ–Π»Π° Ρ†ΠΈΠΊΠ»Ρƒ. ## Continue to the next iteration [#continue] From cb35dc75537be536eba680a4ab1dcdbc7603344e Mon Sep 17 00:00:00 2001 From: tarasyyyk Date: Sun, 15 Mar 2020 14:41:13 +0200 Subject: [PATCH 4/7] Translate first task: 'Last loop value' --- 1-js/02-first-steps/12-while-for/1-loop-last-value/task.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/12-while-for/1-loop-last-value/task.md b/1-js/02-first-steps/12-while-for/1-loop-last-value/task.md index 3b847dfa2..bb0d6ef47 100644 --- a/1-js/02-first-steps/12-while-for/1-loop-last-value/task.md +++ b/1-js/02-first-steps/12-while-for/1-loop-last-value/task.md @@ -2,9 +2,9 @@ importance: 3 --- -# Last loop value +# ΠžΡΡ‚Π°Π½Π½Ρ” значСння Ρ†ΠΈΠΊΠ»Ρƒ -What is the last value alerted by this code? Why? +Π―ΠΊΠ΅ останнє значСння Π±ΡƒΠ΄Π΅ Π²ΠΈΠ²Π΅Π΄Π΅Π½ΠΎ Π½Π° Π΅ΠΊΡ€Π°Π½? Π§ΠΎΠΌΡƒ? ```js let i = 3; From eb68d88d006e9472904ee4cf525c238476be61d3 Mon Sep 17 00:00:00 2001 From: tarasyyyk Date: Mon, 8 Jun 2020 17:24:42 +0300 Subject: [PATCH 5/7] Translate 'Loop > #continue' directive --- 1-js/02-first-steps/13-while-for/article.md | 36 ++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/1-js/02-first-steps/13-while-for/article.md b/1-js/02-first-steps/13-while-for/article.md index c59fed0a5..f9f20923a 100644 --- a/1-js/02-first-steps/13-while-for/article.md +++ b/1-js/02-first-steps/13-while-for/article.md @@ -233,28 +233,28 @@ alert( 'Π‘ΡƒΠΌΠ°: ' + sum ); ΠšΠΎΠΌΠ±Ρ–Π½Π°Ρ†Ρ–Ρ «нСскінчСнний Ρ†ΠΈΠΊΠ» + `break`Β» β€” Ρ‡ΡƒΠ΄ΠΎΠ²Π° Ρ€Ρ–Ρ‡ для Ρ‚ΠΈΡ… ситуацій, ΠΊΠΎΠ»ΠΈ ΡƒΠΌΠΎΠ²Π° для пСрСривання Π·Π½Π°Ρ…ΠΎΠ΄ΠΈΡ‚ΡŒΡΡ Π½Π΅ Π½Π° ΠΏΠΎΡ‡Π°Ρ‚ΠΊΡƒ Π°Π±ΠΎ ΠΊΡ–Π½Ρ†Ρ– Ρ†ΠΈΠΊΠ»Ρƒ, Π° всСрСдині (Π°Π±ΠΎ Π½Π°Π²Ρ–Ρ‚ΡŒ Π² Π΄Π΅ΠΊΡ–Π»ΡŒΠΊΠΎΡ… місцях) Ρ‚Ρ–Π»Π° Ρ†ΠΈΠΊΠ»Ρƒ. -## Continue to the next iteration [#continue] +## ΠŸΡ€ΠΎΠ΄ΠΎΠ²ΠΆΠ΅Π½Π½Ρ Π· наступної Ρ–Ρ‚Π΅Ρ€Π°Ρ†Ρ–Ρ— [#continue] -The `continue` directive is a "lighter version" of `break`. It doesn't stop the whole loop. Instead, it stops the current iteration and forces the loop to start a new one (if the condition allows). +Π”ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²Π° `continue` β€” Ρ†Π΅ "полСгшСна вСрсія" `break`. Π’ΠΎΠ½Π° Π½Π΅ зупиняє вСсь Ρ†ΠΈΠΊΠ». ΠΠ°Ρ‚ΠΎΠΌΡ–ΡΡ‚ΡŒ, Π²ΠΎΠ½Π° зупиняє ΠΏΠΎΡ‚ΠΎΡ‡Π½Ρƒ Ρ–Ρ‚Π΅Ρ€Π°Ρ†Ρ–ΡŽ Ρ– ΠΏΠΎΡ‡ΠΈΠ½Π°Ρ” виконання Ρ†ΠΈΠΊΠ»Ρƒ спочатку Π· наступної Ρ–Ρ‚Π΅Ρ€Π°Ρ†Ρ–Ρ— (якщо ΡƒΠΌΠΎΠ²Π° Ρ†ΠΈΠΊΠ»Ρƒ досі Π²Ρ–Ρ€Π½Π°). -We can use it if we're done with the current iteration and would like to move on to the next one. +Π‡Ρ— Π·Ρ€ΡƒΡ‡Π½ΠΎ використовувати ΠΊΠΎΠ»ΠΈ Π·Π°ΠΊΡ–Π½Ρ‡ΠΈΠ»ΠΈ Π· ΠΏΠΎΡ‚ΠΎΡ‡Π½ΠΎΡŽ Ρ–Ρ‚Π΅Ρ€Π°Ρ†Ρ–Ρ”ΡŽ Ρ– Ρ…ΠΎΡ‡Π΅ΠΌΠΎ ΠΏΡ€ΠΎΠ΄ΠΎΠ²ΠΆΠΈΡ‚ΠΈ Π· наступної. -The loop below uses `continue` to output only odd values: +Π¦ΠΈΠΊΠ» Π½ΠΈΠΆΡ‡Π΅ використовує `continue` Ρ‰ΠΎΠ± вивСсти лишС Π½Π΅ΠΏΠ°Ρ€Π½Ρ– значСння: ```js run no-beautify for (let i = 0; i < 10; i++) { - // if true, skip the remaining part of the body + // якщо ΡƒΠΌΠΎΠ²Π° ΡΠΏΡ€Π°Π²Π΄ΠΆΡƒΡ”Ρ‚ΡŒΡΡ, Ρ‚ΠΎΠ΄Ρ– пропускаємо Ρ€Π΅ΡˆΡ‚Ρƒ Ρ‚Ρ–Π»Π° Ρ†ΠΈΠΊΠ»Ρƒ Ρ– ΠΏΠΎΡ‡ΠΈΠ½Π°Ρ”ΠΌΠΎ Π· наступної Ρ–Ρ‚Π΅Ρ€Π°Ρ†Ρ–Ρ— *!*if (i % 2 == 0) continue;*/!* - alert(i); // 1, then 3, 5, 7, 9 + alert(i); // 1, ΠΏΠΎΡ‚Ρ–ΠΌ 3, 5, 7, 9 } ``` -For even values of `i`, the `continue` directive stops executing the body and passes control to the next iteration of `for` (with the next number). So the `alert` is only called for odd values. +Для ΠΏΠ°Ρ€Π½ΠΈΡ… Π·Π½Π°Ρ‡Π΅Π½ΡŒ Π·ΠΌΡ–Π½Π½ΠΎΡ— `i`, Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²Π° `continue` зупиняє виконання Ρ‚Ρ–Π»Π° Ρ†ΠΈΠΊΠ»Ρƒ Ρ– ΠΏΠ΅Ρ€Π΅Π΄Π°Ρ” ΠΊΠΎΠ½Ρ‚Ρ€ΠΎΠ»ΡŒ наступній Ρ–Ρ‚Π΅Ρ€Π°Ρ†Ρ–Ρ— Π² `for` (Π² Ρ†ΡŒΠΎΠΌΡƒ Π²ΠΈΠΏΠ°Π΄ΠΊΡƒ Ρ†Π΅ Π±ΡƒΠ΄Π΅ наступнС число). Π’Π°ΠΊΠΈΠΌ Ρ‡ΠΈΠ½ΠΎΠΌ функція `alert` Π²ΠΈΠΊΠ»ΠΈΠΊΠ°Ρ”Ρ‚ΡŒΡΡ лишС для Π½Π΅ΠΏΠ°Ρ€Π½ΠΈΡ… Π·Π½Π°Ρ‡Π΅Π½ΡŒ Π·ΠΌΡ–Π½Π½ΠΎΡ— `i`. -````smart header="The `continue` directive helps decrease nesting" -A loop that shows odd values could look like this: +````smart header="Π”ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²Π° `continue` Π΄ΠΎΠΏΠΎΠΌΠ°Π³Π°Ρ” Π·ΠΌΠ΅Π½ΡˆΠΈΡ‚ΠΈ Ρ€Ρ–Π²Π΅Π½ΡŒ вкладСності" +Π¦ΠΈΠΊΠ», який ΠΏΠΎΠΊΠ°Π·ΡƒΡ” Π½Π΅ΠΏΠ°Ρ€Π½Ρ– значСння ΠΌΠΎΠΆΠ΅ виглядати Ρ‚Π°ΠΊ: ```js run for (let i = 0; i < 10; i++) { @@ -266,15 +266,15 @@ for (let i = 0; i < 10; i++) { } ``` -From a technical point of view, this is identical to the example above. Surely, we can just wrap the code in an `if` block instead of using `continue`. +Π— Ρ‚Π΅Ρ…Π½Ρ–Ρ‡Π½ΠΎΡ— Ρ‚ΠΎΡ‡ΠΊΠΈ Π·ΠΎΡ€Ρƒ, Ρ†Π΅ΠΉ ΠΏΡ€ΠΈΠΊΠ»Π°Π΄ Ρ–Π΄Π΅Π½Ρ‚ΠΈΡ‡Π½ΠΈΠΉ Ρ‚ΠΎΠΌΡƒ Ρ‰ΠΎ Π²ΠΈΡ‰Π΅. Π—Π²ΠΈΡ‡Π°ΠΉΠ½ΠΎ, ΠΌΠΈ ΠΌΠΎΠΆΠ΅ΠΌΠΎ просто ΠΎΠ±Π³ΠΎΡ€Π½ΡƒΡ‚ΠΈ ΠΊΠΎΠ΄ Π² Π±Π»ΠΎΠΊ `if` Π·Π°ΠΌΡ–ΡΡ‚ΡŒ використання `continue`. -But as a side-effect, this created one more level of nesting (the `alert` call inside the curly braces). If the code inside of `if` is longer than a few lines, that may decrease the overall readability. +АлС ΠΏΠΎΠ±Ρ–Ρ‡Π½ΠΈΠΌ Π΅Ρ„Π΅ΠΊΡ‚ΠΎΠΌ Ρ†ΡŒΠΎΠ³ΠΎ Π±ΡƒΠ΄Π΅ створСння Ρ‰Π΅ ΠΎΠ΄Π½ΠΎΠ³ΠΎ рівня вкладСності (Π²ΠΈΠΊΠ»ΠΈΠΊ `alert` всСрСдині Ρ„Ρ–Π³ΡƒΡ€Π½ΠΈΡ… Π΄ΡƒΠΆΠΎΠΊ). Π―ΠΊΡ‰ΠΎ ΠΊΠΎΠ΄ всСрСдині `if` Π±ΡƒΠ΄Π΅ Π±Ρ–Π»ΡŒΡˆΠΈΠΌ Π·Π° Π΄Π΅ΠΊΡ–Π»ΡŒΠΊΠ° рядків, Ρ‚ΠΎ Ρ†Π΅ ΠΌΠΎΠΆΠ΅ ускладнити Π·Π°Π³Π°Π»ΡŒΠ½Ρƒ Ρ‡ΠΈΡ‚Π°Π±Π΅Π»ΡŒΠ½Ρ–ΡΡ‚ΡŒ ΠΊΠΎΠ΄Ρƒ. ```` -````warn header="No `break/continue` to the right side of '?'" -Please note that syntax constructs that are not expressions cannot be used with the ternary operator `?`. In particular, directives such as `break/continue` aren't allowed there. +````warn header="Π”ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²ΠΈ `break/continue` ΠΏΡ€Π°Π²ΠΎΡ€ΡƒΡ‡ Π²Ρ–Π΄ '?' Π½Π΅ ΠΏΡ€Π°Ρ†ΡŽΡŽΡ‚ΡŒ" +ΠœΠ°ΠΉΡ‚Π΅ Π½Π° ΡƒΠ²Π°Π·Ρ–, Ρ‰ΠΎ Ρ‚Π°ΠΊΡ– синтаксичні конструкції, які Π½Π΅ Ρ” Π²ΠΈΡ€Π°Π·Π°ΠΌΠΈ, Π½Π΅ ΠΌΠΎΠΆΡƒΡ‚ΡŒ використовуватися Π· Ρ‚Π΅Ρ€Π½Π°Ρ€Π½ΠΈΠΌ ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΎΡ€ΠΎΠΌ `?`. ВласнС, Ρ‚Π°ΠΊΡ– Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²ΠΈ як `break/continue` Ρ‚Π°ΠΌ Π½Π΅ Π΄ΠΎΠ·Π²ΠΎΠ»Π΅Π½Ρ–. -For example, if we take this code: +Наприклад, якщо взяти ΠΊΠΎΠ΄: ```js if (i > 5) { @@ -284,16 +284,16 @@ if (i > 5) { } ``` -...and rewrite it using a question mark: +...Ρ– ΠΏΠ΅Ρ€Π΅Ρ€ΠΎΠ±ΠΈΡ‚ΠΈ ΠΉΠΎΠ³ΠΎ Π· використанням Π·Π½Π°ΠΊΠ° питання: ```js no-beautify -(i > 5) ? alert(i) : *!*continue*/!*; // continue isn't allowed here +(i > 5) ? alert(i) : *!*continue*/!*; // використання continue Π² Π½Π΅Π΄ΠΎΠ·Π²ΠΎΠ»Π΅Π½ΠΎΠΌΡƒ місці ``` -...it stops working: there's a syntax error. +...Ρ‚ΠΎ Ρ‚Π°ΠΊΠΈΠΉ ΠΊΠΎΠ΄ пСрСстанС ΠΏΡ€Π°Ρ†ΡŽΠ²Π°Ρ‚ΠΈ: Π²ΠΈΠ½ΠΈΠΊΠ½Π΅ синтаксична ΠΏΠΎΠΌΠΈΠ»ΠΊΠ°. -This is just another reason not to use the question mark operator `?` instead of `if`. +Π¦Π΅ Ρ‰Π΅ ΠΎΠ΄Π½Π° ΠΏΡ€ΠΈΡ‡ΠΈΠ½Π° Π½Π΅ використовувати для ΡƒΠΌΠΎΠ² ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΎΡ€ Π·Π½Π°ΠΊΠ° питання `?`, Π·Π°ΠΌΡ–ΡΡ‚ΡŒ ΠΏΠΎΠ²Π½ΠΎΡ†Ρ–Π½Π½ΠΎΠ³ΠΎ `if`. ```` ## Labels for break/continue From bf029b3c9a3cb70a27d62da370b597f9ee2cdb93 Mon Sep 17 00:00:00 2001 From: tarasyyyk Date: Mon, 15 Jun 2020 21:33:33 +0300 Subject: [PATCH 6/7] Translate small part of 'Label for break/continue' --- 1-js/02-first-steps/13-while-for/article.md | 28 ++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/1-js/02-first-steps/13-while-for/article.md b/1-js/02-first-steps/13-while-for/article.md index f9f20923a..e4629cbfe 100644 --- a/1-js/02-first-steps/13-while-for/article.md +++ b/1-js/02-first-steps/13-while-for/article.md @@ -296,53 +296,53 @@ if (i > 5) { Π¦Π΅ Ρ‰Π΅ ΠΎΠ΄Π½Π° ΠΏΡ€ΠΈΡ‡ΠΈΠ½Π° Π½Π΅ використовувати для ΡƒΠΌΠΎΠ² ΠΎΠΏΠ΅Ρ€Π°Ρ‚ΠΎΡ€ Π·Π½Π°ΠΊΠ° питання `?`, Π·Π°ΠΌΡ–ΡΡ‚ΡŒ ΠΏΠΎΠ²Π½ΠΎΡ†Ρ–Π½Π½ΠΎΠ³ΠΎ `if`. ```` -## Labels for break/continue +## ΠœΡ–Ρ‚ΠΊΠΈ для break/continue -Sometimes we need to break out from multiple nested loops at once. +Π”Π΅ΠΊΠΎΠ»ΠΈ Π½Π°ΠΌ ΠΏΠΎΡ‚Ρ€Ρ–Π±Π½ΠΎ Π²ΠΈΠΉΡ‚ΠΈ Π· ΠΊΡ–Π»ΡŒΠΊΠΎΡ… Π²ΠΊΠ»Π°Π΄Π΅Π½ΠΈΡ… Ρ†ΠΈΠΊΠ»Ρ–Π². -For example, in the code below we loop over `i` and `j`, prompting for the coordinates `(i, j)` from `(0,0)` to `(2,2)`: +Наприклад, Π² ΠΊΠΎΠ΄Ρ– Π½ΠΈΠΆΡ‡Π΅ Ρ” 2 Ρ†ΠΈΠΊΠ»ΠΈ, які ΠΏΡ€ΠΎΡ…ΠΎΠ΄ΡΡ‚ΡŒΡΡ ΠΏΠΎ Π·ΠΌΡ–Π½Π½ΠΈΡ… `i` Ρ‚Π° `j`, Ρ– Π·Π°ΠΏΠΈΡ‚ΡƒΡŽΡ‚ΡŒ Π² користувача ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚ΠΈ `(i, j)` Π²Ρ–Π΄ `(0,0)` Π΄ΠΎ `(2,2)`: ```js run no-beautify for (let i = 0; i < 3; i++) { for (let j = 0; j < 3; j++) { - let input = prompt(`Value at coords (${i},${j})`, ''); + let input = prompt(`ЗначСння Π² ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚Π°Ρ… (${i},${j})`, ''); - // what if we want to exit from here to Done (below)? + // Ρ‰ΠΎ якщо ΠΌΠΈ Ρ…ΠΎΡ‡Π΅ΠΌΠΎ Π²ΠΈΠΉΡ‚ΠΈ звідси Π²Ρ–Π΄Ρ€Π°Π·Ρƒ Π΄ΠΎ 'Π“ΠΎΡ‚ΠΎΠ²ΠΎ!' (Π² Ρ„ΡƒΠ½ΠΊΡ†Ρ–ΡŽ alert Π½ΠΈΠΆΡ‡Π΅)? } } -alert('Done!'); +alert('Π“ΠΎΡ‚ΠΎΠ²ΠΎ!'); ``` -We need a way to stop the process if the user cancels the input. +Нам ΠΏΠΎΡ‚Ρ€Ρ–Π±Π΅Π½ спосіб Π·ΡƒΠΏΠΈΠ½ΠΈΡ‚ΠΈ Ρ†Ρ– Π΄Π²Π° Ρ†ΠΈΠΊΠ»ΠΈ, якщо користувач скасує ввСдСння. -The ordinary `break` after `input` would only break the inner loop. That's not sufficient--labels, come to the rescue! +Π—Π²ΠΈΡ‡Π°ΠΉΠ½ΠΈΠΉ `break` після `input` лишС ΠΏΠ΅Ρ€Π΅Ρ€Π²Π΅ Π²Π½ΡƒΡ‚Ρ€Ρ–ΡˆΠ½Ρ–ΠΉ Ρ†ΠΈΠΊΠ», Π° Π½Π°ΠΌ Ρ†ΡŒΠΎΠ³ΠΎ Π½Π΅Π΄ΠΎΡΡ‚Π°Ρ‚Π½ΡŒΠΎ. Ось Ρ‚ΡƒΡ‚ Π½Π°ΠΌ ΠΏΡ€ΠΈΠ³ΠΎΠ΄ΡΡ‚ΡŒΡΡ ΠΌΡ–Ρ‚ΠΊΠΈ для Ρ†ΠΈΠΊΠ»Ρ–Π²! -A *label* is an identifier with a colon before a loop: +*ΠœΡ–Ρ‚ΠΊΠ°* ΡΠΊΠ»Π°Π΄Π°Ρ”Ρ‚ΡŒΡΡ Π· Ρ–Π΄Π΅Π½Ρ‚ΠΈΡ„Ρ–ΠΊΠ°Ρ‚ΠΎΡ€Π° Ρ‚Π° Π΄Π²ΠΎΠΊΡ€Π°ΠΏΠΊΠΈ ΠΏΠ΅Ρ€Π΅Π΄ Ρ†ΠΈΠΊΠ»ΠΎΠΌ: ```js labelName: for (...) { ... } ``` -The `break ` statement in the loop below breaks out to the label: +Π’ΠΈΡ€Π°Π· `break ` Π² Ρ†ΠΈΠΊΠ»Ρ– Π½ΠΈΠΆΡ‡Π΅ ΡˆΡƒΠΊΠ°Ρ” Π½Π°ΠΉΠ±Π»ΠΈΠΆΡ‡ΠΈΠΉ Ρ†ΠΈΠΊΠ» Π· заданою ΠΌΡ–Ρ‚ΠΊΠΎΡŽ Ρ– ΠΏΠ΅Ρ€Π΅Ρ…ΠΎΠ΄ΠΈΡ‚ΡŒ Π² ΠΉΠΎΠ³ΠΎ ΠΊΡ–Π½Π΅Ρ†ΡŒ: ```js run no-beautify *!*outer:*/!* for (let i = 0; i < 3; i++) { for (let j = 0; j < 3; j++) { - let input = prompt(`Value at coords (${i},${j})`, ''); + let input = prompt(`ЗначСння Π² ΠΊΠΎΠΎΡ€Π΄ΠΈΠ½Π°Ρ‚Π°Ρ… (${i},${j})`, ''); - // if an empty string or canceled, then break out of both loops + // якщо ΠΏΠΎΡ€ΠΎΠΆΠ½Ρ–ΠΉ рядок Π°Π±ΠΎ Бкасувати, Ρ‚ΠΎΠ΄Ρ– Π²ΠΈΡ…Ρ–Π΄ Π· ΠΎΠ±ΠΎΡ… Ρ†ΠΈΠΊΠ»Ρ–Π² if (!input) *!*break outer*/!*; // (*) - // do something with the value... + // Π·Ρ€ΠΎΠ±ΠΈΡ‚ΠΈ Ρ‰ΠΎΡΡŒ Ρ–Π· значСнням... } } -alert('Done!'); +alert('Π“ΠΎΡ‚ΠΎΠ²ΠΎ!'); ``` In the code above, `break outer` looks upwards for the label named `outer` and breaks out of that loop. From a4a7adca94819af3d32ca581f890a16aa7ecd9fd Mon Sep 17 00:00:00 2001 From: tarasyyyk Date: Mon, 14 Sep 2020 13:27:37 +0300 Subject: [PATCH 7/7] Complete translation. --- 1-js/02-first-steps/13-while-for/article.md | 34 ++++++++++----------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/1-js/02-first-steps/13-while-for/article.md b/1-js/02-first-steps/13-while-for/article.md index e4629cbfe..de189d686 100644 --- a/1-js/02-first-steps/13-while-for/article.md +++ b/1-js/02-first-steps/13-while-for/article.md @@ -345,42 +345,42 @@ labelName: for (...) { alert('Π“ΠΎΡ‚ΠΎΠ²ΠΎ!'); ``` -In the code above, `break outer` looks upwards for the label named `outer` and breaks out of that loop. +Π’ ΠΊΠΎΠ΄Ρ– Π²ΠΈΡ‰Π΅, Π²ΠΈΡ€Π°Π· `break outer` ΡˆΡƒΠΊΠ°Ρ” Π·Π²Π΅Ρ€Ρ…Ρƒ ΠΌΡ–Ρ‚ΠΊΡƒ `outer` Ρ– ΠΏΠ΅Ρ€Π΅Ρ€ΠΈΠ²Π°Ρ” Ρ†ΠΈΠΊΠ», ΠΏΠΎΠ·Π½Π°Ρ‡Π΅Π½ΠΈΠΉ Ρ†Ρ–Ρ”ΡŽ ΠΌΡ–Ρ‚ΠΊΠΎΡŽ. -So the control goes straight from `(*)` to `alert('Done!')`. +Π’ΠΎΠΆ виконання ΠΊΠΎΠ΄Ρƒ ΠΏΠ΅Ρ€Π΅ΠΉΠ΄Π΅ Π· місця пСрСривання Ρ†ΠΈΠΊΠ»Ρƒ (ΠΏΠΎΠ·Π½Π°Ρ‡Π΅Π½Π΅ `(*)`) Π΄ΠΎ Ρ„ΡƒΠ½ΠΊΡ†Ρ–Ρ— `alert('Π“ΠΎΡ‚ΠΎΠ²ΠΎ!')`. -We can also move the label onto a separate line: +ΠœΡ–Ρ‚ΠΊΡƒ ΠΌΠΎΠΆΠ½Π° пСрСмістити Π² Π½ΠΎΠ²ΠΈΠΉ рядок: ```js no-beautify outer: for (let i = 0; i < 3; i++) { ... } ``` -The `continue` directive can also be used with a label. In this case, code execution jumps to the next iteration of the labeled loop. +Π’Π°ΠΊΠΎΠΆ ΠΌΡ–Ρ‚ΠΊΠ°ΠΌΠΈ ΠΌΠΎΠΆΠ½Π° використовувати Π· Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²ΠΎΡŽ `continue`. Π’ Ρ‚Π°ΠΊΠΎΠΌΡƒ Ρ€Π°Π·Ρ–, виконання ΠΊΠΎΠ΄Ρƒ пСрСстрибнС Π½Π° наступну Ρ–Ρ‚Π΅Ρ€Π°Ρ†Ρ–ΡŽ ΠΏΠΎΠΌΡ–Ρ‡Π΅Π½ΠΎΠ³ΠΎ Ρ†ΠΈΠΊΠ»Ρƒ. -````warn header="Labels do not allow to \"jump\" anywhere" -Labels do not allow us to jump into an arbitrary place in the code. +````warn header="ΠœΡ–Ρ‚ΠΊΠ°ΠΌ Π½Π΅ Π΄ΠΎΠ·Π²ΠΎΠ»Π΅Π½ΠΎ \"стрибати\" Π±ΡƒΠ΄ΡŒ-Π΄Π΅" +Ми Π½Π΅ ΠΌΠΎΠΆΠ΅ΠΌΠΎ використовувати ΠΌΡ–Ρ‚ΠΊΠΈ, Ρ‰ΠΎΠ± стрибати Π² Π΄ΠΎΠ²Ρ–Π»ΡŒΠ½Π΅ місцС Π² ΠΊΠΎΠ΄Ρ–. -For example, it is impossible to do this: +Наприклад, ось Ρ‚Π°ΠΊΠ΅ Π½Π΅ΠΌΠΎΠΆΠ»ΠΈΠ²ΠΎ Π·Ρ€ΠΎΠ±ΠΈΡ‚ΠΈ: ```js -break label; // doesn't jumps to the label below +break label; // Π½Π΅ стрибнС Π² ΠΌΡ–Ρ‚ΠΊΡƒ label Π½ΠΈΠΆΡ‡Π΅ label: for (...) ``` -A call to `break/continue` is only possible from inside a loop and the label must be somewhere above the directive. +Π’ΠΈΠΊΠ»ΠΈΠΊ `break/continue` ΠΌΠΎΠΆΠ»ΠΈΠ²ΠΈΠΉ лишС всСрСдині Ρ†ΠΈΠΊΠ»Ρƒ Ρ– ΠΌΡ–Ρ‚ΠΊΠΈ ΠΏΠΎΠ²ΠΈΠ½Π½Ρ– Π±ΡƒΡ‚ΠΈ Π²ΠΈΡ‰Π΅ Ρ†ΠΈΡ… Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ². ```` -## Summary +## ΠŸΡ–Π΄ΡΡƒΠΌΠΊΠΈ -We covered 3 types of loops: +Ми Π²ΠΈΠ²Ρ‡ΠΈΠ»ΠΈ 3 Ρ‚ΠΈΠΏΠΈ Ρ†ΠΈΠΊΠ»Ρ–Π²: -- `while` -- The condition is checked before each iteration. -- `do..while` -- The condition is checked after each iteration. -- `for (;;)` -- The condition is checked before each iteration, additional settings available. +- `while` -- ΡƒΠΌΠΎΠ²Π° ΠΏΠ΅Ρ€Π΅Π²Ρ–Ρ€ΡΡ”Ρ‚ΡŒΡΡ ΠΏΠ΅Ρ€Π΅Π΄ коТною Ρ–Ρ‚Π΅Ρ€Π°Ρ†Ρ–Ρ”ΡŽ. +- `do..while` -- ΡƒΠΌΠΎΠ²Π° ΠΏΠ΅Ρ€Π΅Π²Ρ–Ρ€ΡΡ”Ρ‚ΡŒΡΡ після ΠΊΠΎΠΆΠ½ΠΎΡ— Ρ–Ρ‚Π΅Ρ€Π°Ρ†Ρ–Ρ—. +- `for (;;)` -- ΡƒΠΌΠΎΠ²Π° ΠΏΠ΅Ρ€Π΅Π²Ρ–Ρ€ΡΡ”Ρ‚ΡŒΡΡ ΠΏΠ΅Ρ€Π΅Π΄ коТною Ρ–Ρ‚Π΅Ρ€Π°Ρ†Ρ–Ρ”ΡŽ. МоТна Π΄ΠΎΠ΄Π°Ρ‚ΠΊΠΎΠ²ΠΎ Π½Π°Π»Π°ΡˆΡ‚ΠΎΠ²ΡƒΠ²Π°Ρ‚ΠΈ. -To make an "infinite" loop, usually the `while(true)` construct is used. Such a loop, just like any other, can be stopped with the `break` directive. +Π©ΠΎΠ± Π·Ρ€ΠΎΠ±ΠΈΡ‚ΠΈ "нСскінчСнний" Ρ†ΠΈΠΊΠ», Π²ΠΈΠΊΠΎΡ€ΠΈΡΡ‚ΠΎΠ²ΡƒΡŽΡ‚ΡŒ Π²ΠΈΡ€Π°Π· `while(true)`. Π’Π°ΠΊΡ– Ρ†ΠΈΠΊΠ»ΠΈ, як Ρ– Π±ΡƒΠ΄ΡŒ-які Ρ–Π½ΡˆΡ–, ΠΌΠΎΠΆΠ½Π° Π·ΡƒΠΏΠΈΠ½ΠΈΡ‚ΠΈ Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²ΠΎΡŽ `break`. -If we don't want to do anything in the current iteration and would like to forward to the next one, we can use the `continue` directive. +Π―ΠΊΡ‰ΠΎ Π½Π°ΠΌ Π½Π΅ ΠΏΠΎΡ‚Ρ€Ρ–Π±Π½ΠΎ Π½Ρ–Ρ‡ΠΎΠ³ΠΎ Π²ΠΈΠΊΠΎΠ½ΡƒΠ²Π°Ρ‚ΠΈ Π² ΠΏΠΎΡ‚ΠΎΡ‡Π½Ρ–ΠΉ Ρ–Ρ‚Π΅Ρ€Π°Ρ†Ρ–Ρ— Ρ†ΠΈΠΊΠ»Ρƒ, ΠΌΠΈ ΠΌΠΎΠΆΠ΅ΠΌΠΎ пропустити Ρ†ΡŽ Ρ–Ρ‚Π΅Ρ€Π°Ρ†Ρ–ΡŽ Π·Π° допомогою Π΄ΠΈΡ€Π΅ΠΊΡ‚ΠΈΠ²ΠΈ `continue`. -`break/continue` support labels before the loop. A label is the only way for `break/continue` to escape a nested loop to go to an outer one. +`break/continue` ΠΏΡ–Π΄Ρ‚Ρ€ΠΈΠΌΡƒΡŽΡ‚ΡŒ ΠΌΡ–Ρ‚ΠΊΠΈ ΠΏΠ΅Ρ€Π΅Π΄ Ρ†ΠΈΠΊΠ»ΠΎΠΌ. Π›ΠΈΡˆΠ΅ Π·Π° допомогою ΠΌΡ–Ρ‚ΠΎΠΊ `break/continue` ΠΌΠΈ ΠΌΠΎΠΆΠ΅ΠΌΠΎ ΠΏΠ΅Ρ€Π΅Ρ€Π²Π°Ρ‚ΠΈ Π²ΠΊΠ»Π°Π΄Π΅Π½ΠΈΠΉ Ρ†ΠΈΠΊΠ». pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy