From 5154490f69cca88047ed836aca59bc0b3a4ab256 Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Tue, 27 Jul 2021 11:10:14 +1000 Subject: [PATCH 01/24] Update article.md --- .../11-logical-operators/article.md | 68 +++++++++---------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/article.md b/1-js/02-first-steps/11-logical-operators/article.md index 25f8ff7f5..4c470a053 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -1,24 +1,24 @@ -# Logical operators +# Loginiai operatoriai -There are three logical operators in JavaScript: `||` (OR), `&&` (AND), `!` (NOT). +JavaScript yra trys loginiai operatoriai: `||` (OR - arba), `&&` (AND - ir), `!` (NOT - ne). -Although they are called "logical", they can be applied to values of any type, not only boolean. Their result can also be of any type. +Nors jie vadinami "loginiais", juos galima naudoti su bet kokio tipo vertėmis, ne vien loginėmis. Jų rezultatas taip pat gali būti bet kokio tipo. -Let's see the details. +Pažiūrėkime detaliau. ## || (OR) -The "OR" operator is represented with two vertical line symbols: +Dvi vertikalios linijos atstoja "ARBA" operatorių: ```js result = a || b; ``` -In classical programming, the logical OR is meant to manipulate boolean values only. If any of its arguments are `true`, it returns `true`, otherwise it returns `false`. +Klasikiniame programavime, loginis ARBA yra skirtas manipuliuoti tik logines vertes. Jeigu bent vienas jo argumentas yra `true`, tai ir jis grąžina `true`, kitu atveju grąžina `false`. -In JavaScript, the operator is a little bit trickier and more powerful. But first, let's see what happens with boolean values. +JavaScript operatorius yra šiek tiek sudėtingesnis ir galingesnis. Bet visų pirma pažvelkime kas nutinka su loginėmis vertėmis. -There are four possible logical combinations: +Yra keturios įmanomos loginės kombinacijos: ```js run alert( true || true ); // true @@ -27,21 +27,21 @@ alert( true || false ); // true alert( false || false ); // false ``` -As we can see, the result is always `true` except for the case when both operands are `false`. +Kaip matome, rezultatas yra visada `true` išskyrus kai abu operandai yra `false`. -If an operand is not a boolean, it's converted to a boolean for the evaluation. +Jeigu operandas nėra loginis, tai jis paverčiamas logine vertė, kad būtų įvertintas. -For instance, the number `1` is treated as `true`, the number `0` as `false`: +Pavyzdžiui, skaičius `1` laikomas `true`, skaičius `0` laikomas `false`: ```js run -if (1 || 0) { // works just like if( true || false ) +if (1 || 0) { // veikia taip pat kaip ( true || false ) alert( 'truthy!' ); } ``` -Most of the time, OR `||` is used in an `if` statement to test if *any* of the given conditions is `true`. +Dažniausiai ARBA `||` yra naudojamas `if` teiginiuose, kad pratestuotų ar *kuri nors* iš duotų sąlygų yra `true`. -For example: +Pavyzdžiui: ```js run let hour = 9; @@ -49,55 +49,55 @@ let hour = 9; *!* if (hour < 10 || hour > 18) { */!* - alert( 'The office is closed.' ); + alert( 'Ofisas uždarytas.' ); } ``` -We can pass more conditions: +Galime praleisti ir daugiau sąlygų: ```js run let hour = 12; let isWeekend = true; if (hour < 10 || hour > 18 || isWeekend) { - alert( 'The office is closed.' ); // it is the weekend + alert( 'Ofisas uždarytas.' ); // nes savaitgalis } ``` -## OR "||" finds the first truthy value +## ARBA "||" suranda pirmąją truthy vertę -The logic described above is somewhat classical. Now, let's bring in the "extra" features of JavaScript. +Aukščiau apibūdinta logika yra klasikinė. Dabar pridėkime "ekstra" JavaScript savybių. -The extended algorithm works as follows. +Štai kaip veikia išplėstas algoritmas. -Given multiple OR'ed values: +Turint daugybines ARBA vertes: ```js result = value1 || value2 || value3; ``` -The OR `||` operator does the following: +ARBA `||` operatorius atlieka sekančius veiksmus: -- Evaluates operands from left to right. -- For each operand, converts it to boolean. If the result is `true`, stops and returns the original value of that operand. -- If all operands have been evaluated (i.e. all were `false`), returns the last operand. +- Įvertina operandus iš kairės į dešinę. +- Kiekvieną operandą paverčia į loginę vertę. Jeigu rezultatas yra `true`, sustoja ir grąžina orginalią operando vertę. +- Jeigu visi operandai įvertinti (pvz. visi buvo `false`), grąžinamas paskutinis operandas. -A value is returned in its original form, without the conversion. +Vertė grąžinama savo originalioje formoje be konversijos. -In other words, a chain of OR `"||"` returns the first truthy value or the last one if no truthy value is found. +Kitaip sakant ARBA `"||"` grandinė grąžina pirmąją truthy vertę arba pačią paskutinę vertę, jeigu teisinga vertė nebuvo rasta. -For instance: +Pavyzdžiui: ```js run -alert( 1 || 0 ); // 1 (1 is truthy) -alert( true || 'no matter what' ); // (true is truthy) +alert( 1 || 0 ); // 1 (1 yra truthy) +alert( true || 'nesvarbu kas' ); // (true yra truthy) -alert( null || 1 ); // 1 (1 is the first truthy value) -alert( null || 0 || 1 ); // 1 (the first truthy value) -alert( undefined || null || 0 ); // 0 (all falsy, returns the last value) +alert( null || 1 ); // 1 (1 yra pirmoji truthy vertė) +alert( null || 0 || 1 ); // 1 (pirmoji truthy vertė) +alert( undefined || null || 0 ); // 0 (visos falsy, grąžinama paskutinė vertė) ``` -This leads to some interesting usage compared to a "pure, classical, boolean-only OR". +Tai veda prie labai įdomių panaudojimo būdų, lyginant su "grynu, klasikiniu, loginiu ARBA". 1. **Getting the first truthy value from a list of variables or expressions.** From f48ad01ff2ab83d415e481e674e89e02fe6984f0 Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Tue, 27 Jul 2021 15:47:06 +1000 Subject: [PATCH 02/24] Update article.md --- .../11-logical-operators/article.md | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/article.md b/1-js/02-first-steps/11-logical-operators/article.md index 4c470a053..6abf37a3a 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -99,41 +99,41 @@ alert( undefined || null || 0 ); // 0 (visos falsy, grąžinama paskutinė vert Tai veda prie labai įdomių panaudojimo būdų, lyginant su "grynu, klasikiniu, loginiu ARBA". -1. **Getting the first truthy value from a list of variables or expressions.** +1. **Gaunant pirmą truthy vertę iš kintamųjų ar išraiškų sąrašo.** - Imagine we have a list of variables which can either contain data or be `null/undefined`. How can we find the first one with data? + Įsivaizduokite, kad turime sąrašą kintamųjų, kuriuose arba yra duomenys arba `null/undefined`. Kaip mums surasti pirmąjį su duomenimis? - We can use OR `||`: + Galime naudoti ARBA `||`: ```js run let currentUser = null; let defaultUser = "John"; *!* - let name = currentUser || defaultUser || "unnamed"; + let name = currentUser || defaultUser || "bevardis"; */!* - alert( name ); // selects "John" – the first truthy value + alert( name ); // pasirenka "John" – pirmąją truthy vertę ``` - If both `currentUser` and `defaultUser` were falsy, `"unnamed"` would be the result. -2. **Short-circuit evaluation.** + Jeigu abu `currentUser` ir `defaultUser` būtų falsy, rezultatas būtų `"bevardis"`. +2. **Supaprastintas įvertinimas.** - Operands can be not only values, but arbitrary expressions. OR evaluates and tests them from left to right. The evaluation stops when a truthy value is reached, and the value is returned. This process is called "a short-circuit evaluation" because it goes as short as possible from left to right. + Operandai gali būti ne tik vertės, bet ir sutartinės išraiškos. ARBA juos įvertina ir testuoja iš kairės į dešinę. Įvertinimas sustoja kai pasiekiama truthy vertė ir ta vertė sugrąžinama. Toks procesas yra vadinamas "supaprastintu įvertinimu" (ang. "a short-circuit evaluation"), nes jis vyksta taip trumpai iš kairės į dešinę kaip tik įmanoma. - This is clearly seen when the expression given as the second argument has a side effect like a variable assignment. + Tai labai akivaizdu kai išraiška, duota kaip antras argumentas, turi tokį šalutinį efektą kaip kintamojo priskyrimą. - In the example below, `x` does not get assigned: + Pavyzdyje žemiau `x` nėra priskiriamas: ```js run no-beautify let x; *!*true*/!* || (x = 1); - alert(x); // undefined, because (x = 1) not evaluated + alert(x); // undefined, nes (x = 1) nėra įvertinamas ``` - If, instead, the first argument is `false`, `||` evaluates the second one, thus running the assignment: + Tačiau jeigu pirmas argumentas yra `false`, `||` įvertina antrąjį, tada įvykdomas priskyrimas: ```js run no-beautify let x; @@ -143,21 +143,21 @@ Tai veda prie labai įdomių panaudojimo būdų, lyginant su "grynu, klasikiniu, alert(x); // 1 ``` - An assignment is a simple case. There may be side effects, that won't show up if the evaluation doesn't reach them. + Asignavimas yra paprastas atvejis. Tam gali būti šalutinių efektų, kurie nepasirodys, jeigu įvertinimas jų nepasieks. - As we can see, such a use case is a "shorter way of doing `if`". The first operand is converted to boolean. If it's false, the second one is evaluated. + Kaip matote toks naudojimo atvejis yra "trumpesnis būdas" su `if`". Pirmasis operandas paverčiamas logine verte, antrasis įvertinamas. - Most of time, it's better to use a "regular" `if` to keep the code easy to understand, but sometimes this can be handy. + Dažniausiai, geriau naudoti "įprastinį" `if`, kad kodas būtų lengviau įskaitomas, bet kartais toks būdas gali būti naudingas. -## && (AND) +## && (IR) -The AND operator is represented with two ampersands `&&`: +IR operatorių atstovauja du ampersandai `&&`: ```js result = a && b; ``` -In classical programming, AND returns `true` if both operands are truthy and `false` otherwise: +Klasikiniame programavime, IR grąžina `true` tik tokiu atveju kai abu operandai yra arba truthy, arba `false`: ```js run alert( true && true ); // true @@ -166,45 +166,45 @@ alert( true && false ); // false alert( false && false ); // false ``` -An example with `if`: +Pavyzdys su `if`: ```js run let hour = 12; let minute = 30; if (hour == 12 && minute == 30) { - alert( 'The time is 12:30' ); + alert( 'Dabar yra 12:30' ); } ``` -Just as with OR, any value is allowed as an operand of AND: +Taip kaip ir su ARBA, bet kokia vertė gali būti IR operandu: ```js run -if (1 && 0) { // evaluated as true && false - alert( "won't work, because the result is falsy" ); +if (1 && 0) { // įvertintas kaip true && false + alert( "neveiks, nes rezultatas yra falsy" ); } ``` -## AND "&&" finds the first falsy value +## IR "&&" suranda pirmą falsy vertę -Given multiple AND'ed values: +Turint daug AND verčių: ```js result = value1 && value2 && value3; ``` -The AND `&&` operator does the following: +Operatorius IR `&&` veikia sekančiai: -- Evaluates operands from left to right. -- For each operand, converts it to a boolean. If the result is `false`, stops and returns the original value of that operand. -- If all operands have been evaluated (i.e. all were truthy), returns the last operand. +- Įvertina operandus iš kairės į dešinę. +- Kiekvieną operandą paverčia į loginę vertę. Jeigu rezultatas yra `false`, sustoja ir grąžina originalią operando vertę. +- Jeigu visi operandai buvo įvertinti (pvz. visi buvo truthy), grąžina paskutinį operandą. -In other words, AND returns the first falsy value or the last value if none were found. +Kitais žodžiais IR grąžina pirmą falsy vertę arba jeigu tokių nerado, pačią paskutinę vertę. -The rules above are similar to OR. The difference is that AND returns the first *falsy* value while OR returns the first *truthy* one. +Taisklės aukščiau yra panašios į ARBA. Skirtumas toks, kad IR grąžina pirmą *falsy* vertę kai tuo tarpu ARBA grąžina pirmą *truthy* vertę. -Examples: +Pavyzdžiai: ```js run // if the first operand is truthy, From 1ebf7830164049cb7e432ed9995658f1f8c5287c Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Tue, 27 Jul 2021 21:16:01 +1000 Subject: [PATCH 03/24] Translated article.md --- .../11-logical-operators/article.md | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/article.md b/1-js/02-first-steps/11-logical-operators/article.md index 6abf37a3a..1dbec4e4a 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -53,7 +53,7 @@ if (hour < 10 || hour > 18) { } ``` -Galime praleisti ir daugiau sąlygų: +Galime paleisti ir daugiau sąlygų: ```js run let hour = 12; @@ -145,9 +145,9 @@ Tai veda prie labai įdomių panaudojimo būdų, lyginant su "grynu, klasikiniu, Asignavimas yra paprastas atvejis. Tam gali būti šalutinių efektų, kurie nepasirodys, jeigu įvertinimas jų nepasieks. - Kaip matote toks naudojimo atvejis yra "trumpesnis būdas" su `if`". Pirmasis operandas paverčiamas logine verte, antrasis įvertinamas. + Kaip matote toks naudojimo atvejis yra "trumpesnis būdas" nei `if`". Pirmasis operandas paverčiamas logine verte, antrasis įvertinamas. - Dažniausiai, geriau naudoti "įprastinį" `if`, kad kodas būtų lengviau įskaitomas, bet kartais toks būdas gali būti naudingas. + Vis dėlto dažniausiai, geriau naudoti "įprastinį" `if`, kad kodas būtų lengviau įskaitomas, bet kartais toks būdas gali būti naudingas. ## && (IR) @@ -188,7 +188,7 @@ if (1 && 0) { // įvertintas kaip true && false ## IR "&&" suranda pirmą falsy vertę -Turint daug AND verčių: +Turint daug IR verčių: ```js result = value1 && value2 && value3; @@ -202,102 +202,102 @@ Operatorius IR `&&` veikia sekančiai: Kitais žodžiais IR grąžina pirmą falsy vertę arba jeigu tokių nerado, pačią paskutinę vertę. -Taisklės aukščiau yra panašios į ARBA. Skirtumas toks, kad IR grąžina pirmą *falsy* vertę kai tuo tarpu ARBA grąžina pirmą *truthy* vertę. +Taisyklės aukščiau yra panašios į ARBA. Skirtumas toks, kad IR grąžina pirmą *falsy* vertę kai tuo tarpu ARBA grąžina pirmą *truthy* vertę. Pavyzdžiai: ```js run -// if the first operand is truthy, -// AND returns the second operand: +// jeigu pirmasis operandas yra truthy, +// IR grąžins antrąjį operandą: alert( 1 && 0 ); // 0 alert( 1 && 5 ); // 5 -// if the first operand is falsy, -// AND returns it. The second operand is ignored +// jeigu pirmasis operandas yra falsy, +// IR jį grąžins. Antrasis operandas ignoruojamas alert( null && 5 ); // null -alert( 0 && "no matter what" ); // 0 +alert( 0 && "nesvarbu kas" ); // 0 ``` -We can also pass several values in a row. See how the first falsy one is returned: +Mes taip pat galime praleisti kelias vertes iš eilės. Atkreipkite dėmesį kaip yra grąžinamas pirmasis falsy: ```js run alert( 1 && 2 && null && 3 ); // null ``` -When all values are truthy, the last value is returned: +Kai visos vertės yra truthy, grąžinama paskutinė vertė: ```js run -alert( 1 && 2 && 3 ); // 3, the last one +alert( 1 && 2 && 3 ); // 3, paskutinis ``` -````smart header="Precedence of AND `&&` is higher than OR `||`" -The precedence of AND `&&` operator is higher than OR `||`. +````smart header="IR `&&` pirmenybė yra aukštesnė už ARBA `||`" +IR `&&` operatoriaus pirmenybė yra aukštesnė už ARBA `||`. -So the code `a && b || c && d` is essentially the same as if the `&&` expressions were in parentheses: `(a && b) || (c && d)`. +Tad kodas `a && b || c && d` būtų tas pats lyg `&&` išraiškos būtų tarp skliaustelių: `(a && b) || (c && d)`. ```` -Just like OR, the AND `&&` operator can sometimes replace `if`. +Taip pat kaip ir ARBA, operatorius IR `&&` kartais gali pakeisti `if`. -For instance: +Pavyzdžiui: ```js run let x = 1; -(x > 0) && alert( 'Greater than zero!' ); +(x > 0) && alert( 'Didesnis nei nulis!' ); ``` -The action in the right part of `&&` would execute only if the evaluation reaches it. That is, only if `(x > 0)` is true. +Veiksmas dešinėje `&&` pusėję įvyktų tik tokiu atveju jeigu įvertinimas jį pasiektų. Tai yra, jeigu `(x > 0)` yra tiesa. -So we basically have an analogue for: +Tad mes tiesiog turime analogą šiai išraiškai: ```js run let x = 1; if (x > 0) { - alert( 'Greater than zero!' ); + alert( 'Didesnis nei nulis!' ); } ``` -The variant with `&&` appears shorter. But `if` is more obvious and tends to be a little bit more readable. +Variantas su `&&` atrodo trumpesnis. Bet `if` yra labiau akivaizdus ir dėl to yra geriau įskaitomas. -So we recommend using every construct for its purpose: use `if` if we want if and use `&&` if we want AND. +Mes rekomenduojame naudoti kiekvieną konstruktą pagal paskirtį: naudokite `if` jeigu norite if, o `&&` jeigu norite IR. -## ! (NOT) +## ! (NE) -The boolean NOT operator is represented with an exclamation sign `!`. +Loginis NE operatorius yra atsotvaujamas šauktuko ženklo `!`. -The syntax is pretty simple: +Sintaksė paprasta: ```js result = !value; ``` -The operator accepts a single argument and does the following: +Operatorius priima vieną argumentą ir atlieka sekančius veiksmus: -1. Converts the operand to boolean type: `true/false`. -2. Returns the inverse value. +1. Konvertuoja operatorių į loginę vertę: `true/false`. +2. Grąžina atvirkštinę vertę. -For instance: +Pavyzdžiui: ```js run alert( !true ); // false alert( !0 ); // true ``` -A double NOT `!!` is sometimes used for converting a value to boolean type: +Dvigubas NE `!!` kartais naudojamas, kad paverstų vertę į loginį tipą: ```js run -alert( !!"non-empty string" ); // true +alert( !!"ne tuščia eilutė" ); // true alert( !!null ); // false ``` -That is, the first NOT converts the value to boolean and returns the inverse, and the second NOT inverses it again. In the end, we have a plain value-to-boolean conversion. +Tai yra, pirmasis NE paverčia vertę į loginę ir grąžina atvirkštinį variantą, o antrasis NE jį atverčia atgalios. Galų gale turime paprastą konversiją į loginę vertę. -There's a little more verbose way to do the same thing -- a built-in `Boolean` function: +Yra kiek mažiau žodžių reikalaujantis kelias, kuris daro tą patį -- iš anksto paruošta loginė `Boolean` funkcija: ```js run -alert( Boolean("non-empty string") ); // true +alert( Boolean("ne tuščia eilutė") ); // true alert( Boolean(null) ); // false ``` -The precedence of NOT `!` is the highest of all logical operators, so it always executes first, before `&&` or `||`. +Pirmenybė NE `!` yra aukščiausia iš visų loginių operatorių, tad jis visada įvykdomas pirmiau nei `&&` ar `||`. From 063cf6343fde0e3267d55386a1f87c85d18d2583 Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Wed, 28 Jul 2021 13:50:33 +1000 Subject: [PATCH 04/24] Translated task.md --- .../11-logical-operators/1-alert-null-2-undefined/task.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/task.md b/1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/task.md index a7c9addfc..3ab89d93c 100644 --- a/1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/task.md +++ b/1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/task.md @@ -2,9 +2,9 @@ importance: 5 --- -# What's the result of OR? +# Koks bus ARBA rezultatas? -What is the code below going to output? +Ką atiduos žemiau esantis kodas? ```js alert( null || 2 || undefined ); From 673d6a163e673079b7cb9f6d77d95c66c5215d5e Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Wed, 28 Jul 2021 13:51:17 +1000 Subject: [PATCH 05/24] Translated solution.md --- .../11-logical-operators/1-alert-null-2-undefined/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/solution.md b/1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/solution.md index 8869d32e6..f37a0aa9b 100644 --- a/1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/solution.md +++ b/1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/solution.md @@ -1,4 +1,4 @@ -The answer is `2`, that's the first truthy value. +Atsakymas yra `2`, pirmoji truthy vertė. ```js run alert( null || 2 || undefined ); From 3cec1b7e1bd8389e3c0b4589ba9db5811d416482 Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Wed, 28 Jul 2021 13:52:44 +1000 Subject: [PATCH 06/24] Translated task.md --- 1-js/02-first-steps/11-logical-operators/2-alert-or/task.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/2-alert-or/task.md b/1-js/02-first-steps/11-logical-operators/2-alert-or/task.md index 3908fa2ec..6c1145686 100644 --- a/1-js/02-first-steps/11-logical-operators/2-alert-or/task.md +++ b/1-js/02-first-steps/11-logical-operators/2-alert-or/task.md @@ -2,9 +2,9 @@ importance: 3 --- -# What's the result of OR'ed alerts? +# Koks bus ARBA alert rezultatas? -What will the code below output? +Ką atiduos žemiau esantis kodas? ```js alert( alert(1) || 2 || alert(3) ); From 2320cffa5c8ddd607036d5a5b39005f59d89ed06 Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Wed, 28 Jul 2021 13:57:21 +1000 Subject: [PATCH 07/24] Translated solution.md --- .../11-logical-operators/2-alert-or/solution.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/2-alert-or/solution.md b/1-js/02-first-steps/11-logical-operators/2-alert-or/solution.md index 8f4d664e8..5f245ea4c 100644 --- a/1-js/02-first-steps/11-logical-operators/2-alert-or/solution.md +++ b/1-js/02-first-steps/11-logical-operators/2-alert-or/solution.md @@ -1,13 +1,13 @@ -The answer: first `1`, then `2`. +Atsakymas yra: pirma `1`, tada `2`. ```js run alert( alert(1) || 2 || alert(3) ); ``` -The call to `alert` does not return a value. Or, in other words, it returns `undefined`. +Šaukimas `alert` negrąžina jokios vertės. Arba kitaip sakant, jis grąžina `undefined`. -1. The first OR `||` evaluates it's left operand `alert(1)`. That shows the first message with `1`. -2. The `alert` returns `undefined`, so OR goes on to the second operand searching for a truthy value. -3. The second operand `2` is truthy, so the execution is halted, `2` is returned and then shown by the outer alert. +1. Pirmasis ARBA `||` įvertina kairėje esantį operandą `alert(1)`. Jis parodo žinutę su `1`. +2. `alert` grąžina `undefined`, tad ARBA eina prie sekančio operando ieškodamas truthy vertės. +3. Antrasis operandas `2` yra truthy, tad operacija sustabdoma, grąžinamas `2` ir parodomas per išorinį alert. -There will be no `3`, because the evaluation does not reach `alert(3)`. +Nebebus `3`, nes įvertinimas nepasiekia `alert(3)`. From a0acd3dd763928c859df68ece683933a266ecc4f Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Wed, 28 Jul 2021 13:58:32 +1000 Subject: [PATCH 08/24] Translated task.md --- .../11-logical-operators/3-alert-1-null-2/task.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/task.md b/1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/task.md index 043d431e4..9ddb4739e 100644 --- a/1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/task.md +++ b/1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/task.md @@ -2,9 +2,9 @@ importance: 5 --- -# What is the result of AND? +# Koks yra IR rezultatas? -What is this code going to show? +Ką parodys žemiau esantis kodas? ```js alert( 1 && null && 2 ); From a85d7ad48e73626d4c5b68e176e9f5341a5c2450 Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Wed, 28 Jul 2021 13:59:22 +1000 Subject: [PATCH 09/24] Translated solution.md --- .../11-logical-operators/3-alert-1-null-2/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/solution.md b/1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/solution.md index 5c2455ef4..6fc02355f 100644 --- a/1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/solution.md +++ b/1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/solution.md @@ -1,4 +1,4 @@ -The answer: `null`, because it's the first falsy value from the list. +Atsakymas: `null`, nes tai yra pirmoji falsy vertė sąraše. ```js run alert( 1 && null && 2 ); From da3283ac293f121f4d16ca508ed9b69cc1731062 Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Wed, 28 Jul 2021 14:00:27 +1000 Subject: [PATCH 10/24] Translated task.md --- 1-js/02-first-steps/11-logical-operators/4-alert-and/task.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/4-alert-and/task.md b/1-js/02-first-steps/11-logical-operators/4-alert-and/task.md index 69f877b95..55b84cc7a 100644 --- a/1-js/02-first-steps/11-logical-operators/4-alert-and/task.md +++ b/1-js/02-first-steps/11-logical-operators/4-alert-and/task.md @@ -2,9 +2,9 @@ importance: 3 --- -# What is the result of AND'ed alerts? +# Koks yra IR alerts rezultatas? -What will this code show? +Kas parodys kodas esantis žemiau? ```js alert( alert(1) && alert(2) ); From 535e08c8780cd01a46d20332d2d0751ed125d301 Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Wed, 28 Jul 2021 14:03:11 +1000 Subject: [PATCH 11/24] Translated solution.md --- .../11-logical-operators/4-alert-and/solution.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/4-alert-and/solution.md b/1-js/02-first-steps/11-logical-operators/4-alert-and/solution.md index b6fb10d72..4967d56f3 100644 --- a/1-js/02-first-steps/11-logical-operators/4-alert-and/solution.md +++ b/1-js/02-first-steps/11-logical-operators/4-alert-and/solution.md @@ -1,10 +1,10 @@ -The answer: `1`, and then `undefined`. +Atsakymas: `1`, ir tada `undefined`. ```js run alert( alert(1) && alert(2) ); ``` -The call to `alert` returns `undefined` (it just shows a message, so there's no meaningful return). +Šaukimas `alert` grąžina `undefined` (tiesiog parodo žinutę, tad nebus prasmingo grąžinimo). -Because of that, `&&` evaluates the left operand (outputs `1`), and immediately stops, because `undefined` is a falsy value. And `&&` looks for a falsy value and returns it, so it's done. +Dėl to `&&` įvertina kairį operandą (parodo `1`), ir iš karto sustoja, nes `undefined` yra falsy vertė. O `&&` ieško falsy vertės ir ją grąžina, ir sustoja. From d8bc3828e57339b714ca22eab97b5b04eff8aee5 Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Thu, 29 Jul 2021 15:54:49 +1000 Subject: [PATCH 12/24] Translated task.md --- .../11-logical-operators/5-alert-and-or/task.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/5-alert-and-or/task.md b/1-js/02-first-steps/11-logical-operators/5-alert-and-or/task.md index b18bb9c51..80434e263 100644 --- a/1-js/02-first-steps/11-logical-operators/5-alert-and-or/task.md +++ b/1-js/02-first-steps/11-logical-operators/5-alert-and-or/task.md @@ -2,9 +2,9 @@ importance: 5 --- -# The result of OR AND OR +# ARBA IR ARBA rezultatas -What will the result be? +Koks bus rezultatas? ```js alert( null || 2 && 3 || 4 ); From 419f3a4bdc786f078166672a81cbf692c1567df4 Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Thu, 29 Jul 2021 15:58:34 +1000 Subject: [PATCH 13/24] Translated solution.md --- .../11-logical-operators/5-alert-and-or/solution.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/5-alert-and-or/solution.md b/1-js/02-first-steps/11-logical-operators/5-alert-and-or/solution.md index 25e3568f8..aecc5ef0d 100644 --- a/1-js/02-first-steps/11-logical-operators/5-alert-and-or/solution.md +++ b/1-js/02-first-steps/11-logical-operators/5-alert-and-or/solution.md @@ -1,16 +1,16 @@ -The answer: `3`. +Atsakymas: `3`. ```js run alert( null || 2 && 3 || 4 ); ``` -The precedence of AND `&&` is higher than `||`, so it executes first. +IR `&&` pirmenybė yra aukštesnė už `||`, tad jis įvykdomas pirmiau. -The result of `2 && 3 = 3`, so the expression becomes: +Rezultatas yra `2 && 3 = 3`, tad išraiška tampa: ``` null || 3 || 4 ``` -Now the result is the first truthy value: `3`. +Dabar rezultatas yra pirmoji truthy vertė: `3`. From 50143ee41e7e513f49068f08a3f93bf3380b1aeb Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Thu, 29 Jul 2021 16:01:06 +1000 Subject: [PATCH 14/24] Translated task.md --- .../11-logical-operators/6-check-if-in-range/task.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/6-check-if-in-range/task.md b/1-js/02-first-steps/11-logical-operators/6-check-if-in-range/task.md index cc00ca9fc..8999dbb78 100644 --- a/1-js/02-first-steps/11-logical-operators/6-check-if-in-range/task.md +++ b/1-js/02-first-steps/11-logical-operators/6-check-if-in-range/task.md @@ -2,8 +2,8 @@ importance: 3 --- -# Check the range between +# Patikrinkite intervalą -Write an "if" condition to check that `age` is between `14` and `90` inclusively. +Parašykite "if" sąlygą, kuri patikrintų ar `age` yra tarp `14` ir `90` įskaitant. -"Inclusively" means that `age` can reach the edges `14` or `90`. +"Įskaitant" reiškia, kad `age` gali pasiekti `14` ir `90` ribas. From b4be9ee3675fb38436611f53327d89ffa6632bbb Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Thu, 29 Jul 2021 16:03:49 +1000 Subject: [PATCH 15/24] Translated task.md --- .../11-logical-operators/7-check-if-out-range/task.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/7-check-if-out-range/task.md b/1-js/02-first-steps/11-logical-operators/7-check-if-out-range/task.md index 7c22d6ad1..5787cc419 100644 --- a/1-js/02-first-steps/11-logical-operators/7-check-if-out-range/task.md +++ b/1-js/02-first-steps/11-logical-operators/7-check-if-out-range/task.md @@ -2,8 +2,8 @@ importance: 3 --- -# Check the range outside +# Patikrinkite už intervalo ribų -Write an `if` condition to check that `age` is NOT between 14 and 90 inclusively. +Parašykite `if` sąlygą, kuri patikrintų ar `age` nėra tarp 14 ir 90 įskaitant. -Create two variants: the first one using NOT `!`, the second one -- without it. +Sukurkite du variantus: vieną naudojant NE `!`, kitą nenaudojant jo. From 4bcffb3d4fc5e7473cd954988a51f98b6ba9e4fd Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Thu, 29 Jul 2021 16:04:27 +1000 Subject: [PATCH 16/24] Translated solution.md --- .../11-logical-operators/7-check-if-out-range/solution.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/7-check-if-out-range/solution.md b/1-js/02-first-steps/11-logical-operators/7-check-if-out-range/solution.md index d1946a967..6019dd8eb 100644 --- a/1-js/02-first-steps/11-logical-operators/7-check-if-out-range/solution.md +++ b/1-js/02-first-steps/11-logical-operators/7-check-if-out-range/solution.md @@ -1,10 +1,10 @@ -The first variant: +Pirmas variantas: ```js if (!(age >= 14 && age <= 90)) ``` -The second variant: +Antras variantas: ```js if (age < 14 || age > 90) From 7fa2669f90810b7b3e65e2e7490fe0138ee8b7eb Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Thu, 29 Jul 2021 16:06:55 +1000 Subject: [PATCH 17/24] Translated task.md --- .../11-logical-operators/8-if-question/task.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/8-if-question/task.md b/1-js/02-first-steps/11-logical-operators/8-if-question/task.md index 55987121b..0c1c2f8cf 100644 --- a/1-js/02-first-steps/11-logical-operators/8-if-question/task.md +++ b/1-js/02-first-steps/11-logical-operators/8-if-question/task.md @@ -2,15 +2,15 @@ importance: 5 --- -# A question about "if" +# Klausimas apie "if" -Which of these `alert`s are going to execute? +Kurie iš šių `alert`s bus įvykdyti? -What will the results of the expressions be inside `if(...)`? +Koks bus išraiškų rezultatas viduje `if(...)`? ```js -if (-1 || 0) alert( 'first' ); -if (-1 && 0) alert( 'second' ); -if (null || -1 && 1) alert( 'third' ); +if (-1 || 0) alert( 'pirmas' ); +if (-1 && 0) alert( 'antras' ); +if (null || -1 && 1) alert( 'trečias' ); ``` From f8cb281b69e0960e7b89672e718e366f605cc2d9 Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Thu, 29 Jul 2021 16:09:20 +1000 Subject: [PATCH 18/24] Translated solution.md --- .../8-if-question/solution.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/8-if-question/solution.md b/1-js/02-first-steps/11-logical-operators/8-if-question/solution.md index 210509758..10f5cd004 100644 --- a/1-js/02-first-steps/11-logical-operators/8-if-question/solution.md +++ b/1-js/02-first-steps/11-logical-operators/8-if-question/solution.md @@ -1,20 +1,20 @@ -The answer: the first and the third will execute. +Atsakymas: pirma ir antra bus įvykdytos. Details: ```js run -// Runs. -// The result of -1 || 0 = -1, truthy -if (-1 || 0) alert( 'first' ); +// Paleidžiama. +// Rezultatas iš -1 || 0 = -1, truthy +if (-1 || 0) alert( 'pirmas' ); -// Doesn't run +// Nepaleidžiamas // -1 && 0 = 0, falsy -if (-1 && 0) alert( 'second' ); +if (-1 && 0) alert( 'antras' ); -// Executes -// Operator && has a higher precedence than || -// so -1 && 1 executes first, giving us the chain: +// Įvykdomas +// Operatorius && turi aukštesnį prioritetą negu || +// tad -1 && 1 įvykdomas pirmiau, sukurdamas mums grandinę: // null || -1 && 1 -> null || 1 -> 1 -if (null || -1 && 1) alert( 'third' ); +if (null || -1 && 1) alert( 'trečias' ); ``` From b040cb7bdb47603b00d2718f76eef348b56378a5 Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Thu, 29 Jul 2021 16:15:42 +1000 Subject: [PATCH 19/24] Translated task.md --- .../9-check-login/task.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/9-check-login/task.md b/1-js/02-first-steps/11-logical-operators/9-check-login/task.md index 290a52642..9a8ff28f2 100644 --- a/1-js/02-first-steps/11-logical-operators/9-check-login/task.md +++ b/1-js/02-first-steps/11-logical-operators/9-check-login/task.md @@ -2,24 +2,24 @@ importance: 3 --- -# Check the login +# Patikrinti prisijungimą -Write the code which asks for a login with `prompt`. +Parašykite kodą, kuris prašo prisijungimo su `prompt`. -If the visitor enters `"Admin"`, then `prompt` for a password, if the input is an empty line or `key:Esc` -- show "Canceled", if it's another string -- then show "I don't know you". +Jeigu lankytojas įveda `"Admin"`, tada `prompt` slaptažodžio, jeigu įvedama tuščia eilė arba paspaudžiamas `key:Esc` -- parodyti "Atšaukta", jeigu tai kitokia eilutė -- tada parodyti "Aš jūsų nežinau". -The password is checked as follows: +Slaptažodis patikrinamas sekančiais žingsniais: -- If it equals "TheMaster", then show "Welcome!", -- Another string -- show "Wrong password", -- For an empty string or cancelled input, show "Canceled" +- Jeigu lygus "TheMaster", parodyti "Sveiki!", +- Kitokia eilutė -- parodyti "Neteisingas slaptažodis", +- Tuščiai eilutei arba jeigu buvo atšauktas, parodyti "Atšauktas" -The schema: +Diagrama: ![](ifelse_task.svg) -Please use nested `if` blocks. Mind the overall readability of the code. +Prašau, naudokite įdėtinius (ang. "nested") `if` rinkinius. Prižiūrėkite skaitomumą viso kodo -Hint: passing an empty input to a prompt returns an empty string `''`. Pressing `key:ESC` during a prompt returns `null`. +Patarimas: praleidžiant tuščią įvestį per prompt grąžina tuščią eilutę `''`. Paspaudžiant `key:ESC` per prompt grąžina `null`. [demo] From bffa68d8c847e7cd52c085ae6055d177f5217fa2 Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Thu, 5 Aug 2021 06:36:30 +1000 Subject: [PATCH 20/24] Translated solution.md --- .../9-check-login/solution.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/1-js/02-first-steps/11-logical-operators/9-check-login/solution.md b/1-js/02-first-steps/11-logical-operators/9-check-login/solution.md index a30db7aae..58898b294 100644 --- a/1-js/02-first-steps/11-logical-operators/9-check-login/solution.md +++ b/1-js/02-first-steps/11-logical-operators/9-check-login/solution.md @@ -1,25 +1,25 @@ ```js run demo -let userName = prompt("Who's there?", ''); +let userName = prompt("Kas čia?", ''); if (userName == 'Admin') { - let pass = prompt('Password?', ''); + let pass = prompt('Slaptažodis?', ''); if (pass == 'TheMaster') { - alert( 'Welcome!' ); + alert( 'Sveiki!' ); } else if (pass == '' || pass == null) { - alert( 'Canceled' ); + alert( 'Atšaukta' ); } else { - alert( 'Wrong password' ); + alert( 'Neteisingas slaptažodis' ); } } else if (userName == '' || userName == null) { - alert( 'Canceled' ); + alert( 'Atšaukta' ); } else { - alert( "I don't know you" ); + alert( "Aš jūsų nepažįstu" ); } ``` -Note the vertical indents inside the `if` blocks. They are technically not required, but make the code more readable. +Atkreipkite dėmesį į vertikalius įgilėjimus viduje `if` rinkinio. Techniškai jie nėra būtini, bet jie paverčia kodą lengviau skaitomu. From e1323a73b4668dc9480ca8dfc02100a275d81853 Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Thu, 5 Aug 2021 06:41:10 +1000 Subject: [PATCH 21/24] Translated ifelse_task.svg --- .../11-logical-operators/9-check-login/ifelse_task.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg b/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg index cbc8c7840..f08072094 100644 --- a/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg +++ b/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg @@ -1 +1 @@ -BeginCanceledCanceledWelcome!I don't know youWrong passwordWho's there?Password?CancelCancelAdminTheMasterOtherOther \ No newline at end of file +PradžiaAtšauktaAtšauktaSveiki!Aš jūsų nepažįstuNeteisingas slaptažodisKas čia?Slaptžodis?AtšauktiAtšauktiAdminTheMasterKitaOther From 46f8d2c4feb2db8af1a0e100e95715bbcfa2ca9e Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Thu, 5 Aug 2021 06:42:33 +1000 Subject: [PATCH 22/24] Translated ifelse_task.svg --- .../11-logical-operators/9-check-login/ifelse_task.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg b/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg index f08072094..69069d244 100644 --- a/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg +++ b/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg @@ -1 +1 @@ -PradžiaAtšauktaAtšauktaSveiki!Aš jūsų nepažįstuNeteisingas slaptažodisKas čia?Slaptžodis?AtšauktiAtšauktiAdminTheMasterKitaOther +PradžiaAtšauktaAtšauktaSveiki!Aš jūsų nepažįstuNeteisingas slaptažodisKas čia?Slaptžodis?AtšauktiAtšauktiAdminTheMasterKitaOther From 360ba3749a9bb59d42afc9e6e0ca2a19fd099418 Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Thu, 5 Aug 2021 06:43:22 +1000 Subject: [PATCH 23/24] Translated ifelse_task.svg --- .../11-logical-operators/9-check-login/ifelse_task.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg b/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg index 69069d244..a8dcb3444 100644 --- a/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg +++ b/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg @@ -1 +1 @@ -PradžiaAtšauktaAtšauktaSveiki!Aš jūsų nepažįstuNeteisingas slaptažodisKas čia?Slaptžodis?AtšauktiAtšauktiAdminTheMasterKitaOther +PradžiaAtšauktaAtšauktaSveiki!Aš jūsų nepažįstuNeteisingas slaptažodisKas čia?Slaptžodis?AtšauktiAtšauktiAdminTheMasterKitaKita From a4518ed94fca1623c0f62308c3dcdd261d18d3af Mon Sep 17 00:00:00 2001 From: Ginja <30539630+meilune@users.noreply.github.com> Date: Thu, 5 Aug 2021 06:44:30 +1000 Subject: [PATCH 24/24] Translated ifelse_task.svg --- .../11-logical-operators/9-check-login/ifelse_task.svg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg b/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg index a8dcb3444..1c45adeaf 100644 --- a/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg +++ b/1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg @@ -1 +1 @@ -PradžiaAtšauktaAtšauktaSveiki!Aš jūsų nepažįstuNeteisingas slaptažodisKas čia?Slaptžodis?AtšauktiAtšauktiAdminTheMasterKitaKita +PradžiaAtšauktaAtšauktaSveiki!Aš jūsų nepažįstuNeteisingas slaptažodisKas čia?Slaptžodis?AtšauktiAtšauktiAdminTheMasterKitaKita