From eb51f731dc12f97d2509876f793e55d14d979b46 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Tue, 3 Aug 2021 01:45:03 +0400 Subject: [PATCH 01/26] article.md to line 19 --- .../11-logical-operators/article.md | 150 +++++++++--------- 1 file changed, 75 insertions(+), 75 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 97f5d738a..7c08bf02c 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -1,30 +1,30 @@ -# Logical operators +# Տրամաբանական օպերատորներ (Logical operators) -There are four logical operators in JavaScript: `||` (OR), `&&` (AND), `!` (NOT), `??` (Nullish Coalescing). Here we cover the first three, the `??` operator is in the next article. +JavaScript-ում կան չորս տրամաբանական օպերատորներ՝ `||` (ԿԱՄ), `&&` (ԵՎ), `!` (ՈՉ), `??` (Null-ի հետ համակցման). Այստեղ մենք կծանոթանանք առաջին երեքին։ `??` օպերատորին կարող եք ծանոթանալ հաջորդ հոդվածում։ -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. +Չնայած նրանք անվանվում են "տրամաբանական", նրանք կարող են կիրառվել կամայական(տարբերվող տրամաբանական տիպից) տիպի վրա։ Նրանց արդյունքը նույպես կարող է լինել կամայական տիպի։ -Let's see the details. +Եկեք դիտարկենք ավելի մանրամասն։ -## || (OR) +## || (ԿԱՄ) -The "OR" operator is represented with two vertical line symbols: +"ԿԱՄ" օպերատորը ներկայացվում է երկու ուղղահայաց գիծ նշանների միջոցով։ ```js -result = a || b; +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`. +Կլասիկ ծրագրավորման մեջ տրամաբանական ԿԱՄ օպերատորը կիրառվում է միայն տրամաբանական արժեքների վրա։ Եթե նրա արգումենտներից մեկը ճշմարի `true` է, ապա այն վերադարձնում է `true`, հակառակ դեպքում՝ `false`։ In JavaScript, the operator is a little bit trickier and more powerful. But first, let's see what happens with boolean values. There are four possible logical combinations: ```js run -alert( true || true ); // true -alert( false || true ); // true -alert( true || false ); // true -alert( false || false ); // false +alert(true || true) // true +alert(false || true) // true +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`. @@ -34,12 +34,13 @@ If an operand is not a boolean, it's converted to a boolean for the evaluation. For instance, the number `1` is treated as `true`, the number `0` as `false`: ```js run -if (1 || 0) { // works just like if( true || false ) - alert( 'truthy!' ); +if (1 || 0) { + // works just like if( 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`. +Most of the time, OR `||` is used in an `if` statement to test if _any_ of the given conditions is `true`. For example: @@ -56,11 +57,11 @@ if (hour < 10 || hour > 18) { We can pass more conditions: ```js run -let hour = 12; -let isWeekend = true; +let hour = 12 +let isWeekend = true if (hour < 10 || hour > 18 || isWeekend) { - alert( 'The office is closed.' ); // it is the weekend + alert('The office is closed.') // it is the weekend } ``` @@ -73,7 +74,7 @@ The extended algorithm works as follows. Given multiple OR'ed values: ```js -result = value1 || value2 || value3; +result = value1 || value2 || value3 ``` The OR `||` operator does the following: @@ -89,96 +90,96 @@ In other words, a chain of OR `||` returns the first truthy value or the last on For instance: ```js run -alert( 1 || 0 ); // 1 (1 is truthy) +alert(1 || 0) // 1 (1 is truthy) -alert( null || 1 ); // 1 (1 is the first truthy value) -alert( null || 0 || 1 ); // 1 (the first truthy value) +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(undefined || null || 0) // 0 (all falsy, returns the last value) ``` This leads to some interesting usage compared to a "pure, classical, boolean-only OR". 1. **Getting the first truthy value from a list of variables or expressions.** - For instance, we have `firstName`, `lastName` and `nickName` variables, all optional (i.e. can be undefined or have falsy values). + For instance, we have `firstName`, `lastName` and `nickName` variables, all optional (i.e. can be undefined or have falsy values). - Let's use OR `||` to choose the one that has the data and show it (or `"Anonymous"` if nothing set): + Let's use OR `||` to choose the one that has the data and show it (or `"Anonymous"` if nothing set): - ```js run - let firstName = ""; - let lastName = ""; - let nickName = "SuperCoder"; + ```js run + let firstName = ""; + let lastName = ""; + let nickName = "SuperCoder"; - *!* - alert( firstName || lastName || nickName || "Anonymous"); // SuperCoder - */!* - ``` + *!* + alert( firstName || lastName || nickName || "Anonymous"); // SuperCoder + */!* + ``` - If all variables were falsy, `"Anonymous"` would show up. + If all variables were falsy, `"Anonymous"` would show up. 2. **Short-circuit evaluation.** - Another feature of OR `||` operator is the so-called "short-circuit" evaluation. + Another feature of OR `||` operator is the so-called "short-circuit" evaluation. - It means that `||` processes its arguments until the first truthy value is reached, and then the value is returned immediately, without even touching the other argument. + It means that `||` processes its arguments until the first truthy value is reached, and then the value is returned immediately, without even touching the other argument. - That importance of this feature becomes obvious if an operand isn't just a value, but an expression with a side effect, such as a variable assignment or a function call. + That importance of this feature becomes obvious if an operand isn't just a value, but an expression with a side effect, such as a variable assignment or a function call. - In the example below, only the second message is printed: + In the example below, only the second message is printed: - ```js run no-beautify - *!*true*/!* || alert("not printed"); - *!*false*/!* || alert("printed"); - ``` + ```js run no-beautify + *!*true*/!* || alert("not printed"); + *!*false*/!* || alert("printed"); + ``` - In the first line, the OR `||` operator stops the evaluation immediately upon seeing `true`, so the `alert` isn't run. + In the first line, the OR `||` operator stops the evaluation immediately upon seeing `true`, so the `alert` isn't run. - Sometimes, people use this feature to execute commands only if the condition on the left part is falsy. + Sometimes, people use this feature to execute commands only if the condition on the left part is falsy. ## && (AND) The AND operator is represented with two ampersands `&&`: ```js -result = a && b; +result = a && b ``` In classical programming, AND returns `true` if both operands are truthy and `false` otherwise: ```js run -alert( true && true ); // true -alert( false && true ); // false -alert( true && false ); // false -alert( false && false ); // false +alert(true && true) // true +alert(false && true) // false +alert(true && false) // false +alert(false && false) // false ``` An example with `if`: ```js run -let hour = 12; -let minute = 30; +let hour = 12 +let minute = 30 if (hour == 12 && minute == 30) { - alert( 'The time is 12:30' ); + alert('The time is 12:30') } ``` Just as with OR, any value is allowed as an operand of AND: ```js run -if (1 && 0) { // evaluated as true && false - alert( "won't work, because the result is falsy" ); +if (1 && 0) { + // evaluated as true && false + alert("won't work, because the result is falsy") } ``` - ## AND "&&" finds the first falsy value Given multiple AND'ed values: ```js -result = value1 && value2 && value3; +result = value1 && value2 && value3 ``` The AND `&&` operator does the following: @@ -189,39 +190,39 @@ The AND `&&` operator does the following: In other words, AND returns the first falsy value or the last value if none were found. -The rules above are similar to OR. The difference is that AND returns the first *falsy* value while OR returns the first *truthy* one. +The rules above are similar to OR. The difference is that AND returns the first _falsy_ value while OR returns the first _truthy_ one. Examples: ```js run // if the first operand is truthy, // AND returns the second operand: -alert( 1 && 0 ); // 0 -alert( 1 && 5 ); // 5 +alert(1 && 0) // 0 +alert(1 && 5) // 5 // if the first operand is falsy, // AND returns it. The second operand is ignored -alert( null && 5 ); // null -alert( 0 && "no matter what" ); // 0 +alert(null && 5) // null +alert(0 && 'no matter what') // 0 ``` We can also pass several values in a row. See how the first falsy one is returned: ```js run -alert( 1 && 2 && null && 3 ); // null +alert(1 && 2 && null && 3) // null ``` When all values are truthy, the last value is returned: ```js run -alert( 1 && 2 && 3 ); // 3, the last one +alert(1 && 2 && 3) // 3, the last one ``` -````smart header="Precedence of AND `&&` is higher than OR `||`" -The precedence of AND `&&` operator is higher than OR `||`. +````smart header="Precedence of AND `&&`is higher than OR`||`" The precedence of AND `&&`operator is higher than OR`||`. So the code `a && b || c && d` is essentially the same as if the `&&` expressions were in parentheses: `(a && b) || (c && d)`. -```` + +````` ````warn header="Don't replace `if` with `||` or `&&`" Sometimes, people use the AND `&&` operator as a "shorter way to write `if`". @@ -245,8 +246,7 @@ if (x > 0) alert( 'Greater than zero!' ); ``` Although, the variant with `&&` appears shorter, `if` is more obvious and tends to be a little bit more readable. So we recommend using every construct for its purpose: use `if` if we want `if` and use `&&` if we want AND. -```` - +````` ## ! (NOT) @@ -255,7 +255,7 @@ The boolean NOT operator is represented with an exclamation sign `!`. The syntax is pretty simple: ```js -result = !value; +result = !value ``` The operator accepts a single argument and does the following: @@ -266,15 +266,15 @@ The operator accepts a single argument and does the following: For instance: ```js run -alert( !true ); // false -alert( !0 ); // true +alert(!true) // false +alert(!0) // true ``` A double NOT `!!` is sometimes used for converting a value to boolean type: ```js run -alert( !!"non-empty string" ); // true -alert( !!null ); // false +alert(!!'non-empty string') // 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. @@ -282,8 +282,8 @@ That is, the first NOT converts the value to boolean and returns the inverse, an There's a little more verbose way to do the same thing -- a built-in `Boolean` function: ```js run -alert( Boolean("non-empty string") ); // true -alert( Boolean(null) ); // false +alert(Boolean('non-empty string')) // true +alert(Boolean(null)) // false ``` The precedence of NOT `!` is the highest of all logical operators, so it always executes first, before `&&` or `||`. From 27c1964798b7c8db920f5c73a2228b4f6a01b15c Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Tue, 3 Aug 2021 23:10:16 +0400 Subject: [PATCH 02/26] OR operator ended --- .../11-logical-operators/article.md | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 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 7c08bf02c..47e3d8979 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -16,9 +16,9 @@ result = a || b Կլասիկ ծրագրավորման մեջ տրամաբանական ԿԱՄ օպերատորը կիրառվում է միայն տրամաբանական արժեքների վրա։ Եթե նրա արգումենտներից մեկը ճշմարի `true` է, ապա այն վերադարձնում է `true`, հակառակ դեպքում՝ `false`։ -In JavaScript, the operator is a little bit trickier and more powerful. But first, let's see what happens with boolean values. +JavaScript֊ում այս օպերատորը ավելի ճկուն և հզոր է։ Բայց սկզում եկեք տեսնենք, թե ինչ է կատարվում տրամաբանական տիպերի հետ։ -There are four possible logical combinations: +Կան չորս տրամաբանական կոմբինայիաներ․ ```js run alert(true || true) // true @@ -27,22 +27,22 @@ 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`. +Ինչպես տեսնում ենք արդյունքը միշտ ճիշտ(`true`) է, բացի այն դեպքից, երբ երկու օպերանդներն էլ սխալ(`false`) են։ If an operand is not a boolean, it's converted to a boolean for the evaluation. -For instance, the number `1` is treated as `true`, the number `0` as `false`: +Օրինակ `1`֊ը մշակվում է որպես `true`, `0`֊ն՝ `false`․ ```js run if (1 || 0) { - // works just like if( true || false ) - alert('truthy!') + // աշխատում է ինչպես if( true || false ) + alert('Ճշմարիտ է!') } ``` -Most of the time, OR `||` is used in an `if` statement to test if _any_ of the given conditions is `true`. +Շատ հաճախ ԿԱՄ `||` օպերատորը օգտագործվում է `if` պայմանի օպերատորի հետ՝ ստուգելու համար արդյոք ճիշտ(`true`) է տրված պայմաններից _գոնե մեկը_։ -For example: +Օրինակ․ ```js run let hour = 9; @@ -50,61 +50,61 @@ let hour = 9; *!* if (hour < 10 || hour > 18) { */!* - alert( 'The office is closed.' ); + alert('Գրասենյակը փակ է։'); } ``` -We can pass more conditions: +Մենք կարող ենք ստուգել ավելի շատ պայմաններ․ ```js run let hour = 12 let isWeekend = true if (hour < 10 || hour > 18 || isWeekend) { - alert('The office is closed.') // it is the weekend + alert('Գրասենյակը փակ է։') // քանի որ շաբաթ կամ կիրակի է (weekend) } ``` -## OR "||" finds the first truthy value [#or-finds-the-first-truthy-value] +## ԿԱՄ "||"֊ը գտնում է առաջին ճշմարիտ արժեքը [#or-finds-the-first-truthy-value] -The logic described above is somewhat classical. Now, let's bring in the "extra" features of JavaScript. +Վերոնշյալ տրամաբանությունը ստանդարտ է ԿԱՄ֊ի համար։ Հիմա եկեք դիտարկենք JavaScript֊ի "հավելյալ" հատկությունները։ -The extended algorithm works as follows. +Ընդլայնված ալգորիթմը աշխատում է հետևյալ կերպ։ -Given multiple OR'ed values: +Տրված են մի քանի ԿԱՄ֊ով կապված արժեքներ․ ```js result = value1 || value2 || value3 ``` -The OR `||` operator does the following: +ԿԱՄ `||` օպերատորը կատարում է հետևյալ քայլերը․ -- 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. +- Հաշվում է օպերանդների արժեքները ձախից աջ։ +- Ամեն օպերանդի արժեք փոխակերպում է տրամաբանական տիպի։ Եթե արդյունքը `true` է այն կանգ է առնում և վերադարձնում այդ օպերանդի օրիգինալ արժեքը։ +- Եթե բոլոր օպերանդները հաշվվում են, և բոլորի արժեքը `false` է լինում, ապա վերադարձնում է վերջին օպերանդի արժեքը։ -A value is returned in its original form, without the conversion. +Արժեքը վերադարձվում է իր օրիգինալ վիճակում, առանց փոխարկման(conversion)։ -In other words, a chain of OR `||` returns the first truthy value or the last one if no truthy value is found. +Այլ կերպ ասած, ԿԱՄ `||`֊երից կազմված շղթան վերադարձնում է առաջին ճշմարիտ արժեքը, կամ վերջինը, եթե չկան ճշմարիտ արժեքներ։ -For instance: +Օրինակ․ ```js run -alert(1 || 0) // 1 (1 is truthy) +alert(1 || 0) // 1 (1֊ը ճշմարիտ է) -alert(null || 1) // 1 (1 is the first truthy value) -alert(null || 0 || 1) // 1 (the first truthy value) +alert(null || 1) // 1 (1֊ը առաջին ճշմարիտ արժեքն է) +alert(null || 0 || 1) // 1 (առաջին ճշմարիտ արժեքը) -alert(undefined || null || 0) // 0 (all falsy, returns the last value) +alert(undefined || null || 0) // 0 (քանի որ բոլորը սխալական(falsy) են, վերադարձնում է վերջինը) ``` -This leads to some interesting usage compared to a "pure, classical, boolean-only OR". +Սա հնարավորություն է տալիս կիրառել օպերատորը "մաքուր, ստանդարտ, միայն տրամաբանական ԿԱՄ"֊ի շրջանակներից դուրս։ -1. **Getting the first truthy value from a list of variables or expressions.** +1. **Առաջին ճշմարիտ արժեքի ստացումը փոփոխականների կամ արտահայտությունների ցուցակից։** - For instance, we have `firstName`, `lastName` and `nickName` variables, all optional (i.e. can be undefined or have falsy values). + Օրինակի, ունենք `firstName`, `lastName` և `nickName` փոփոխականները, բոլորը ըստ ցանկության կարող են ստանալ սխալական կամ `undefined` արժեքներ։ - Let's use OR `||` to choose the one that has the data and show it (or `"Anonymous"` if nothing set): + Եկեք օգտագործենք ԿԱՄ `||`֊ը ընտրելու համար մեկը որը ունի արժեք(ճշմարիտ) և ցույց տանք այն (կամ `"Anonymous"` եթե այդպիսի արժեք չի գտնվել): ```js run let firstName = ""; @@ -116,26 +116,26 @@ This leads to some interesting usage compared to a "pure, classical, boolean-onl */!* ``` - If all variables were falsy, `"Anonymous"` would show up. + Եթե բոլոր փոփոխականները լինեին սխալական, ապա կտեսնեինք `"Anonymous"`։ -2. **Short-circuit evaluation.** +2. **Կրճատ հաշվարկ (Short-circuit evaluation)։** - Another feature of OR `||` operator is the so-called "short-circuit" evaluation. + ԿԱՄ `||`֊ի մեկ այլ հատկությունը այսպես կոչված "կրճատ հաշվարկ"֊ի հատկությունն է։ - It means that `||` processes its arguments until the first truthy value is reached, and then the value is returned immediately, without even touching the other argument. + Դա նշանակում է, որ `||`֊ը կատարում է իր արգումենտների հաշվարկը և փոխակերպումը տրամաբանական տիպի մինչև առաջին ճշմարիտ արժեքին հանդիպելը, ապա այդ արժեքը միանգամից վերադարձվում է, առանց նույնիսկ հաջորդ արգումենտներին նայելու։ - That importance of this feature becomes obvious if an operand isn't just a value, but an expression with a side effect, such as a variable assignment or a function call. + Այս հատկության կարևորությունն ակնհայտ է դառնում, եթե օպերանդը պարզապես արժեք չէ, այլ ինչ֊որ արտահայտություն՝ կողմնակի ազդեցությամբ, օրինակ փոփոխականի վերագրում կամ ֆունկցիայի կանչ։ - In the example below, only the second message is printed: + Ներքևի օրինակում միայն երկրորդ նամակը կերևա էկրանին․ ```js run no-beautify - *!*true*/!* || alert("not printed"); - *!*false*/!* || alert("printed"); + *!*true*/!* || alert("չի երևա"); + *!*false*/!* || alert("կերևա"); ``` - In the first line, the OR `||` operator stops the evaluation immediately upon seeing `true`, so the `alert` isn't run. + Առաջին տողում ԿԱՄ `||` օպերատորը անմիջապես դադարեցնում է հաշվարկը հենց հանդիպում է `true` արժեքին, այդ պատճառով `alert`֊ը չի կանչվում։ - Sometimes, people use this feature to execute commands only if the condition on the left part is falsy. + Հաճախ ծրագրավորողները օգտագործում են այս հատկությունը այն դեպքում, երբ անհրաժեշտ է կատարել հրամանները(execute commands) այն և միայն այն դեպքում, երբ ձախ կողմի գրված պայմանը սխալական է։ ## && (AND) From 7a0456e09d33c0248321acaf775fc9ab43ff2321 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Thu, 5 Aug 2021 00:40:00 +0400 Subject: [PATCH 03/26] && translated --- .../11-logical-operators/article.md | 65 ++++++++++--------- 1 file changed, 33 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 47e3d8979..60d23d124 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -14,7 +14,7 @@ JavaScript-ում կան չորս տրամաբանական օպերատորնե result = a || b ``` -Կլասիկ ծրագրավորման մեջ տրամաբանական ԿԱՄ օպերատորը կիրառվում է միայն տրամաբանական արժեքների վրա։ Եթե նրա արգումենտներից մեկը ճշմարի `true` է, ապա այն վերադարձնում է `true`, հակառակ դեպքում՝ `false`։ +Դասական ծրագրավորման մեջ տրամաբանական ԿԱՄ օպերատորը կիրառվում է միայն տրամաբանական արժեքների վրա։ Եթե նրա արգումենտներից մեկը ճշմարի `true` է, ապա այն վերադարձնում է `true`, հակառակ դեպքում՝ `false`։ JavaScript֊ում այս օպերատորը ավելի ճկուն և հզոր է։ Բայց սկզում եկեք տեսնենք, թե ինչ է կատարվում տրամաբանական տիպերի հետ։ @@ -137,15 +137,15 @@ alert(undefined || null || 0) // 0 (քանի որ բոլորը սխալական( Հաճախ ծրագրավորողները օգտագործում են այս հատկությունը այն դեպքում, երբ անհրաժեշտ է կատարել հրամանները(execute commands) այն և միայն այն դեպքում, երբ ձախ կողմի գրված պայմանը սխալական է։ -## && (AND) +## && (ԵՎ) -The AND operator is represented with two ampersands `&&`: +ԵՎ օպերատորը ներկայացվում է երկու ամպերսանդի նշանների միջոցով `&&`։ ```js result = a && b ``` -In classical programming, AND returns `true` if both operands are truthy and `false` otherwise: +Դասական ծրագրավորման մեջ ԵՎ օպերատորը վերադարձնում է `true`, եթե իր երկու օպերանդների արժեքները ճշմերիտ են, հակառակ դեպքում՝ `false`։ ```js run alert(true && true) // true @@ -154,14 +154,14 @@ alert(true && false) // false alert(false && false) // false ``` -An example with `if`: +Օրինակ `if`֊ի հետ։ ```js run let hour = 12 let minute = 30 if (hour == 12 && minute == 30) { - alert('The time is 12:30') + alert('Ժամը 12:30֊ն է') } ``` @@ -174,78 +174,79 @@ if (1 && 0) { } ``` -## AND "&&" finds the first falsy value +## ԵՎ "&&"֊ը գտնում է առաջին սխալական արժեքը -Given multiple AND'ed values: +Տրված է մի քանի արժեքներ կապակցված ԵՎ֊ով․ ```js result = value1 && value2 && value3 ``` -The AND `&&` operator does the following: +ԵՎ `&&` օպերատորը կատարում է հետևյալ գործողություննեը․ -- 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. +- Հաշվում է օպերանդների արժեքները ձախից աջ։ +- Ամեն օպերանդի արժեք փոխակերպում է տրամաբանական տիպի։ Եթե արդյունքը `false` է այն կանգ է առնում և վերադարձնում այդ օպերանդի օրիգինալ արժեքը։ +- Եթե բոլոր օպերանդները հաշվվում են, և բոլորի արժեքը `true` է լինում, ապա վերադարձնում է վերջին օպերանդի արժեքը։ In other words, AND returns the first falsy value or the last value if none were found. -The rules above are similar to OR. The difference is that AND returns the first _falsy_ value while OR returns the first _truthy_ one. +Վերոնշյալ կանոնները նման են ԿԱՄ֊ին։ Տարբերությունն այն է, որ ԵՎ֊ը վերադարձնում է առաջին _սխալական_ արժեքը, իսկ ԿԱՄ֊ը՝ առաջին _ճշմարիտ_ արժեքը։ -Examples: +Օրինակներ․ ```js run -// if the first operand is truthy, -// AND returns the second operand: +// Եթե առաջին օպերանդը ճշմարիտ է, +// ապա ԵՎ֊ը վերադարձնում է երկրոդ օպերանդը։ alert(1 && 0) // 0 alert(1 && 5) // 5 -// if the first operand is falsy, -// AND returns it. The second operand is ignored +// Եթե առաջին օպերանդը սխալական է, +// ապա ԵՎ֊ը վերադարձնում է այն։ +// Երկրորդ օպերանդը անտեսվում է։ alert(null && 5) // null -alert(0 && 'no matter what') // 0 +alert(0 && 'կապ չունի ինչ') // 0 ``` -We can also pass several values in a row. See how the first falsy one is returned: +Կարող ենք նաև մի քանի արժեք միաժամանակ փոխանցել։ Տեսնենք թե ինչպես է ԵՎ֊ը վերադարձնում առաջին սխալական արժեքը․ ```js run alert(1 && 2 && null && 3) // null ``` -When all values are truthy, the last value is returned: +Երբ բոլոր արժեքնորը ճշմարիտ են, ապա վերադարձվում է վերջին արժեքը․ ```js run -alert(1 && 2 && 3) // 3, the last one +alert(1 && 2 && 3) // 3, վերջինը ``` -````smart header="Precedence of AND `&&`is higher than OR`||`" The precedence of AND `&&`operator is higher than OR`||`. +````smart header="ԵՎ `&&`֊ի նախապատվությունը(precedence) ավելի բարձր է քան ԿԱՄ `||`֊ինը" -So the code `a && b || c && d` is essentially the same as if the `&&` expressions were in parentheses: `(a && b) || (c && d)`. +Այսպիսով `a && b || c && d` արտահայտությունը համարժեք է հետևյալ արտահայտությանը՝ `(a && b) || (c && d)`, որտեղ `&&`֊երը փակագծերի մեջ են։ ````` -````warn header="Don't replace `if` with `||` or `&&`" -Sometimes, people use the AND `&&` operator as a "shorter way to write `if`". +````warn header="Մի փոխարինեք `if`֊ը `||`֊ով կամ `&&`֊ով" +Հաճախ ծրագրավորողները օգտագործում են ԵՎ `&&` օպերատորը, որպես "`if`֊ի կարճ գրելաձև"։ -For instance: +Օրինակ․ ```js run let x = 1; -(x > 0) && alert( 'Greater than zero!' ); +(x > 0) && alert('Մեծ է զրոից'); ``` -The action in the right part of `&&` would execute only if the evaluation reaches it. That is, only if `(x > 0)` is true. +Աջ կողմի գործողությունը կկատարվի այն ժամանակ, երբ ձախից աջ արժեքավրումը հասնի իրեն(այսինքն ձախ կողմի բոլոր արժեքները ճշմարիտ են)։ Դա տեղի կունենա, եթե `(x > 0)` արտահայտությունը ճիշտ լինի։ -So we basically have an analogue for: +Դա ստացվում է հետևյալի անալոգը․ ```js run let x = 1; -if (x > 0) alert( 'Greater than zero!' ); +if (x > 0) alert('Մեծ է զրոից'); ``` -Although, the variant with `&&` appears shorter, `if` is more obvious and tends to be a little bit more readable. So we recommend using every construct for its purpose: use `if` if we want `if` and use `&&` if we want AND. +Թեև `&&`֊ով տարբերակն ավելի կարճ է, `if`֊ը ավելի հասկանալի է և ավելի ընթեռնելի։ Այսպիսով, մենք խորհուրդ ենք տալիս օգտագործել յուրաքանչյուր գրելաձև իր նշանակությանը համապատասխան՝ օգտագործեք `if` եթե ցանկանում եք պայման ստուգել, և `&&`, եթե ցանկանում եք կատարել ԵՎ տրամաբանական գործողությունը։ ````` ## ! (NOT) From e57228ded9c1d6bc376d4007ce11e0c9ac748e8c Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Thu, 5 Aug 2021 22:11:57 +0400 Subject: [PATCH 04/26] article added --- .../11-logical-operators/article.md | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 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 60d23d124..7b28b0932 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -6,7 +6,7 @@ JavaScript-ում կան չորս տրամաբանական օպերատորնե Եկեք դիտարկենք ավելի մանրամասն։ -## || (ԿԱՄ) +## || (ԿԱՄ) (OR) "ԿԱՄ" օպերատորը ներկայացվում է երկու ուղղահայաց գիծ նշանների միջոցով։ @@ -29,7 +29,7 @@ alert(false || false) // false Ինչպես տեսնում ենք արդյունքը միշտ ճիշտ(`true`) է, բացի այն դեպքից, երբ երկու օպերանդներն էլ սխալ(`false`) են։ -If an operand is not a boolean, it's converted to a boolean for the evaluation. +Եթե օպերանդը տրամաբանական տիպ չի, ապա այն փոխակերպվում(convert) է տրամաբանական տիպի։ Օրինակ `1`֊ը մշակվում է որպես `true`, `0`֊ն՝ `false`․ @@ -104,7 +104,7 @@ alert(undefined || null || 0) // 0 (քանի որ բոլորը սխալական( Օրինակի, ունենք `firstName`, `lastName` և `nickName` փոփոխականները, բոլորը ըստ ցանկության կարող են ստանալ սխալական կամ `undefined` արժեքներ։ - Եկեք օգտագործենք ԿԱՄ `||`֊ը ընտրելու համար մեկը որը ունի արժեք(ճշմարիտ) և ցույց տանք այն (կամ `"Anonymous"` եթե այդպիսի արժեք չի գտնվել): + Եկեք օգտագործենք ԿԱՄ `||`֊ը ընտրելու համար մեկը որը ունի արժեք(ճշմարիտ) և ցույց տանք այն (կամ `"Anonymous"` եթե այդպիսի արժեք չի գտնվել)։ ```js run let firstName = ""; @@ -137,7 +137,7 @@ alert(undefined || null || 0) // 0 (քանի որ բոլորը սխալական( Հաճախ ծրագրավորողները օգտագործում են այս հատկությունը այն դեպքում, երբ անհրաժեշտ է կատարել հրամանները(execute commands) այն և միայն այն դեպքում, երբ ձախ կողմի գրված պայմանը սխալական է։ -## && (ԵՎ) +## && (ԵՎ) (AND) ԵՎ օպերատորը ներկայացվում է երկու ամպերսանդի նշանների միջոցով `&&`։ @@ -161,16 +161,16 @@ let hour = 12 let minute = 30 if (hour == 12 && minute == 30) { - alert('Ժամը 12:30֊ն է') + alert('Ժամը 12։30֊ն է') } ``` -Just as with OR, any value is allowed as an operand of AND: +Ինչպես ԿԱՄ֊ի դեպքում, ԵՎ֊ի օպերանդները նույնպես կարող են ունենալ կամայական արժեք․ ```js run if (1 && 0) { - // evaluated as true && false - alert("won't work, because the result is falsy") + // հաշվվում է ինչպես true && false + alert('չի երևա, որովհետև արժեքը սխալական է') } ``` @@ -249,42 +249,42 @@ if (x > 0) alert('Մեծ է զրոից'); Թեև `&&`֊ով տարբերակն ավելի կարճ է, `if`֊ը ավելի հասկանալի է և ավելի ընթեռնելի։ Այսպիսով, մենք խորհուրդ ենք տալիս օգտագործել յուրաքանչյուր գրելաձև իր նշանակությանը համապատասխան՝ օգտագործեք `if` եթե ցանկանում եք պայման ստուգել, և `&&`, եթե ցանկանում եք կատարել ԵՎ տրամաբանական գործողությունը։ ````` -## ! (NOT) +## ! (ՈՉ) (NOT) -The boolean NOT operator is represented with an exclamation sign `!`. +Տրամաբանական ՈՉ օպերատորը ներկայացվում է բացականչական նշանի միջոցով՝ `!`։ -The syntax is pretty simple: +Նրա շարահյուսությունը(syntax) շատ պարզ է․ ```js result = !value ``` -The operator accepts a single argument and does the following: +Օպերատորը ընդունում է մեկ արգումենտ է կատարում հետևյալ քայլերը․ -1. Converts the operand to boolean type: `true/false`. -2. Returns the inverse value. +1. Փոխակերպում է օպերանդը տրամաբանական տիպի՝ `true/false`. +2. Վերադարձնում է հակադարձ արժեքը։ -For instance: +Օրինակ․ ```js run alert(!true) // false alert(!0) // true ``` -A double NOT `!!` is sometimes used for converting a value to boolean type: +Երբեմն կրկնակի ՈՉ `!!`֊ը օգտագործվում է արժեքը տրամաբանական տիպի փոխակերպելու համար․ ```js run -alert(!!'non-empty string') // true +alert(!!'ոչ դատարկ տողային արժեք') // 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. +Այսինքն՝ առաջին ՈՉ֊ը փոխակերպում է արժեքը տրամաբանական տիպի, և վերադարձնում դրա հակադարձը, իսկ երկրորդ ՈՉ֊ը կրկին հակադարձում է այն։ Վերջնարդյունքում ունենում ենք տրամաբանական տիպի փոխակերպում(value-to-boolean conversion)։ -There's a little more verbose way to do the same thing -- a built-in `Boolean` function: +Այս գործողության ավելի տեսանելի տարբերակը ներկառուցված `Boolean` ֆունկցիայի կիրառմամբ է․ ```js run -alert(Boolean('non-empty string')) // true +alert(Boolean('ոչ դատարկ տողային արժեք')) // true alert(Boolean(null)) // false ``` -The precedence of NOT `!` is the highest of all logical operators, so it always executes first, before `&&` or `||`. +ՈՉ `!` օպերատորի նախապատվությունը ամենաբարձրն է բոլոր տրամաբանական օպերատորների մեջ, այսինքն արտահայտության մեջ միշտ առաջինը կատարվում է `!` գործողությունը, և այնուհետև `&&` և `||` գործողությունները։ From ac13025d70af35ec205e2cad0ab640e28a70ad56 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 6 Aug 2021 00:50:34 +0400 Subject: [PATCH 05/26] importance translated --- .../1-alert-null-2-undefined/task.md | 5 ++--- .../11-logical-operators/2-alert-or/task.md | 5 ++--- .../11-logical-operators/3-alert-1-null-2/task.md | 5 ++--- .../11-logical-operators/4-alert-and/task.md | 5 ++--- .../11-logical-operators/5-alert-and-or/task.md | 5 ++--- .../11-logical-operators/6-check-if-in-range/task.md | 2 +- .../11-logical-operators/7-check-if-out-range/task.md | 2 +- .../11-logical-operators/8-if-question/task.md | 9 ++++----- .../11-logical-operators/9-check-login/task.md | 4 ++-- 9 files changed, 18 insertions(+), 24 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..c89a01145 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 @@ -1,4 +1,4 @@ -importance: 5 +Կարևորություն: 5 --- @@ -7,6 +7,5 @@ importance: 5 What is the code below going to output? ```js -alert( null || 2 || undefined ); +alert(null || 2 || undefined) ``` - 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..268ecd975 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 @@ -1,4 +1,4 @@ -importance: 3 +Կարևորություն: 3 --- @@ -7,6 +7,5 @@ importance: 3 What will the code below output? ```js -alert( alert(1) || 2 || alert(3) ); +alert(alert(1) || 2 || alert(3)) ``` - 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..a036aa4cc 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 @@ -1,4 +1,4 @@ -importance: 5 +Կարևորություն: 5 --- @@ -7,6 +7,5 @@ importance: 5 What is this code going to show? ```js -alert( 1 && null && 2 ); +alert(1 && null && 2) ``` - 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..31c226d42 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 @@ -1,4 +1,4 @@ -importance: 3 +Կարևորություն: 3 --- @@ -7,6 +7,5 @@ importance: 3 What will this code show? ```js -alert( alert(1) && alert(2) ); +alert(alert(1) && alert(2)) ``` - 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..d74b1bf29 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 @@ -1,4 +1,4 @@ -importance: 5 +Կարևորություն: 5 --- @@ -7,6 +7,5 @@ importance: 5 What will the result be? ```js -alert( null || 2 && 3 || 4 ); +alert(null || (2 && 3) || 4) ``` - 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 fc9e336c1..090636ebe 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 @@ -1,4 +1,4 @@ -importance: 3 +Կարևորություն: 3 --- 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 9b947d00f..447a315ae 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 @@ -1,4 +1,4 @@ -importance: 3 +Կարևորություն: 3 --- 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..5f9812e86 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 @@ -1,4 +1,4 @@ -importance: 5 +Կարևորություն: 5 --- @@ -9,8 +9,7 @@ Which of these `alert`s are going to execute? What will the results of the expressions be inside `if(...)`? ```js -if (-1 || 0) alert( 'first' ); -if (-1 && 0) alert( 'second' ); -if (null || -1 && 1) alert( 'third' ); +if (-1 || 0) alert('first') +if (-1 && 0) alert('second') +if (null || (-1 && 1)) alert('third') ``` - 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..8645bdff2 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 @@ -1,4 +1,4 @@ -importance: 3 +Կարևորություն: 3 --- @@ -20,6 +20,6 @@ The schema: Please use nested `if` blocks. Mind the overall readability of the code. -Hint: passing an empty input to a prompt returns an empty string `''`. Pressing `key:ESC` during a prompt returns `null`. +Hint: passing an empty input to a prompt returns an empty string `''`. Pressing `key:ESC` during a prompt returns `null`. [demo] From 6612518c22b784e2f851fd096c8e25de8ba85585 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 6 Aug 2021 00:55:10 +0400 Subject: [PATCH 06/26] 1-alert-null-2-undefined translated --- .../1-alert-null-2-undefined/solution.md | 5 ++--- .../11-logical-operators/1-alert-null-2-undefined/task.md | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) 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..478586635 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,6 +1,5 @@ -The answer is `2`, that's the first truthy value. +Պատասխանը `2` է, քանի որ այն առաջին ճշմարիտ արժեքն է։ ```js run -alert( null || 2 || undefined ); +alert(null || 2 || undefined) ``` - 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 c89a01145..226ed0384 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 @@ --- -# What's the result of OR? +# Ի՞նչ է հետևյալ ԿԱՄ-ով արտահայտության արդյունքը: -What is the code below going to output? +Ի՞նչ կտպի ներքևում գրված ծրագիրը։ ```js alert(null || 2 || undefined) From b662a96c3c4700949e527b0b20f2c852f53a4048 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 6 Aug 2021 01:00:03 +0400 Subject: [PATCH 07/26] 3-alert-1-null-2 translated --- .../11-logical-operators/3-alert-1-null-2/solution.md | 4 ++-- .../11-logical-operators/3-alert-1-null-2/task.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) 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..832e2cede 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,6 +1,6 @@ -The answer: `null`, because it's the first falsy value from the list. +Պատասխանը `null` է, քանի որ այն առաջին սխալական արժեքն է։ ```js run -alert( 1 && null && 2 ); +alert(1 && null && 2) ``` 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 a036aa4cc..2c3458af3 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 @@ --- -# What is the result of AND? +# Ի՞նչ է հետևյալ ԵՎ-ով արտահայտության արդյունքը: -What is this code going to show? +Ի՞նչ կտպի ներքևում գրված ծրագիրը։ ```js alert(1 && null && 2) From c0cdc9a944b1be5430264cd41c2a005148ac5ada Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 6 Aug 2021 21:19:04 +0400 Subject: [PATCH 08/26] 2-alert-or translated --- .../11-logical-operators/2-alert-or/solution.md | 14 +++++++------- .../11-logical-operators/2-alert-or/task.md | 4 ++-- 2 files changed, 9 insertions(+), 9 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 f85b56366..e8aa3387a 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`. +Այն կտպի `1`, այնուհետև `2`։ ```js run -alert( alert(1) || 2 || alert(3) ); +alert(alert(1) || 2 || alert(3)) ``` -The call to `alert` does not return a value. Or, in other words, it returns `undefined`. +`alert`֊ի կանչը չի վերադարձնում ոչ մի արժեք։ Կամ այլ կերպա ասած վերադարձնում է `undefined`։ -1. The first OR `||` evaluates its 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. Սկզբում ԿԱՄ `||`֊ը հաշվում(evaluates) է իր ձախ կողմի օպերանդը՝ `alert(1)`, որն էլ էկրանին ցույց է տալիս `1` արժեքը։ +2. `alert`֊ը վերադարձնում է `undefined`։ ԿԱՄ֊ը անցնում է երկրորդ օպերանդին՝ որոնելով ճշմարիտ արժեք։ +3. Երկրորդ օպերանդը `2` է, որը ճշմարիտ է, և ԿԱՄ֊ը դադարացնում է իր հաշվարկները։ `2`֊ը վերադարձվում է և ցուցադրվում էկրանին դրսի `alert`֊ի միջոցով։ -There will be no `3`, because the evaluation does not reach `alert(3)`. +`3`֊ը չի երևա էկրանին, քանի որ ԿԱՄ֊ը կանգ է առնում երկրորդ օպերանդի վրա և չի հասնում `alert(3)`֊ին։ 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 268ecd975..02b6a436c 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 @@ --- -# What's the result of OR'ed alerts? +# Ի՞նչ է հետևյալ ԿԱՄ-ով արտահայտությունների արդյունքը: -What will the code below output? +Ի՞նչ կտպի ներքևում գրված ծրագիրը։ ```js alert(alert(1) || 2 || alert(3)) From 7646dd526e7b883f8632207156116b51add012be Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 6 Aug 2021 21:19:04 +0400 Subject: [PATCH 09/26] 2-alert-or translated --- .../11-logical-operators/2-alert-or/solution.md | 14 +++++++------- .../11-logical-operators/2-alert-or/task.md | 4 ++-- 2 files changed, 9 insertions(+), 9 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 f85b56366..e8aa3387a 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`. +Այն կտպի `1`, այնուհետև `2`։ ```js run -alert( alert(1) || 2 || alert(3) ); +alert(alert(1) || 2 || alert(3)) ``` -The call to `alert` does not return a value. Or, in other words, it returns `undefined`. +`alert`֊ի կանչը չի վերադարձնում ոչ մի արժեք։ Կամ այլ կերպա ասած վերադարձնում է `undefined`։ -1. The first OR `||` evaluates its 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. Սկզբում ԿԱՄ `||`֊ը հաշվում(evaluates) է իր ձախ կողմի օպերանդը՝ `alert(1)`, որն էլ էկրանին ցույց է տալիս `1` արժեքը։ +2. `alert`֊ը վերադարձնում է `undefined`։ ԿԱՄ֊ը անցնում է երկրորդ օպերանդին՝ որոնելով ճշմարիտ արժեք։ +3. Երկրորդ օպերանդը `2` է, որը ճշմարիտ է, և ԿԱՄ֊ը դադարացնում է իր հաշվարկները։ `2`֊ը վերադարձվում է և ցուցադրվում էկրանին դրսի `alert`֊ի միջոցով։ -There will be no `3`, because the evaluation does not reach `alert(3)`. +`3`֊ը չի երևա էկրանին, քանի որ ԿԱՄ֊ը կանգ է առնում երկրորդ օպերանդի վրա և չի հասնում `alert(3)`֊ին։ 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 268ecd975..3428da187 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 @@ --- -# What's the result of OR'ed alerts? +# Ի՞նչ է հետևյալ ԿԱՄ-ով արտահայտության արդյունքը: -What will the code below output? +Ի՞նչ կտպի ներքևում գրված ծրագիրը։ ```js alert(alert(1) || 2 || alert(3)) From f0d57a555a5715d65b9dd046e555da12df4fc7ba Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 6 Aug 2021 21:29:56 +0400 Subject: [PATCH 10/26] 4-alert-and translated --- .../11-logical-operators/4-alert-and/solution.md | 8 ++++---- .../11-logical-operators/4-alert-and/task.md | 4 ++-- 2 files changed, 6 insertions(+), 6 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..f6dad7201 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`. +Այն կտպի `1`, այնուհետև `undefined`։ ```js run -alert( alert(1) && alert(2) ); +alert(alert(1) && alert(2)); ``` -The call to `alert` returns `undefined` (it just shows a message, so there's no meaningful return). +`alert`֊ի կանչը տպում է էկրանին և վերադարձնում `undefined`։ -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. +Այդ պատճառով, երբ `&&`֊ը ավարտում է ձախ օպերանդի հաշվարկը (էկրանին ցուցադրում է `1`), անմիջապես կանգ է առնում, քանի որ `undefined`֊ը սխալական արժեք է։ `&&`֊ը փնտրում է առաջին սխալական արժեքը և վերադարձնում այն։ 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 31c226d42..5385b06b1 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 @@ --- -# What is the result of AND'ed alerts? +# Ի՞նչ է հետևյալ ԵՎ-ով արտահայտության արդյունքը: -What will this code show? +Ի՞նչ կտպի ներքևում գրված ծրագիրը։ ```js alert(alert(1) && alert(2)) From 54448c2af1e82a78e95708907fc7dffa9f3b1f1a Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 6 Aug 2021 21:48:47 +0400 Subject: [PATCH 11/26] 5-alert-and-or translated --- .../11-logical-operators/5-alert-and-or/solution.md | 8 ++++---- .../11-logical-operators/5-alert-and-or/task.md | 6 +++--- 2 files changed, 7 insertions(+), 7 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..b5f064b66 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`. +Պատասխանը `3` է։ ```js run alert( null || 2 && 3 || 4 ); ``` -The precedence of AND `&&` is higher than `||`, so it executes first. +ԵՎ `&&`֊ի նախապատվությունը ավելի բարձր է քան `||`֊ինը, հետևաբար այն ավելի շուտ կկատարվի։ -The result of `2 && 3 = 3`, so the expression becomes: +Քանի որ `2 && 3 = 3`, ապա կստանանք հետևյալ արտահայտությունը․ ``` null || 3 || 4 ``` -Now the result is the first truthy value: `3`. +Եվ կստանանք պատասխանը առաջին ճշմարիտ արժեքը՝ `3`։ 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 d74b1bf29..edeef4b1c 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,10 +2,10 @@ --- -# The result of OR AND OR +# Ի՞նչ է հետևյալ ԵՎ-ով և ԿԱՄ֊ով արտահայտության արդյունքը: -What will the result be? +Ի՞նչ կտպի ներքևում գրված ծրագիրը։ ```js -alert(null || (2 && 3) || 4) +alert( null || 2 && 3 || 4 ); ``` From 5895fdc86a5c1247c4e42ae9a4240b06f524a585 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 6 Aug 2021 21:55:43 +0400 Subject: [PATCH 12/26] titles rename and 6th ex. --- .../11-logical-operators/1-alert-null-2-undefined/task.md | 2 +- 1-js/02-first-steps/11-logical-operators/2-alert-or/task.md | 2 +- .../02-first-steps/11-logical-operators/4-alert-and/task.md | 2 +- .../11-logical-operators/5-alert-and-or/task.md | 2 +- .../11-logical-operators/6-check-if-in-range/task.md | 6 +++--- 5 files changed, 7 insertions(+), 7 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 226ed0384..27b63d235 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,7 +2,7 @@ --- -# Ի՞նչ է հետևյալ ԿԱՄ-ով արտահայտության արդյունքը: +# Ի՞նչ է հետևյալ ԿԱՄ-ով արտահայտության արդյունքը Ի՞նչ կտպի ներքևում գրված ծրագիրը։ 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 3428da187..bf4578517 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,7 +2,7 @@ --- -# Ի՞նչ է հետևյալ ԿԱՄ-ով արտահայտության արդյունքը: +# Ի՞նչ է հետևյալ ԿԱՄ-ով արտահայտության արդյունքը Ի՞նչ կտպի ներքևում գրված ծրագիրը։ 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 5385b06b1..8b64e2636 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,7 +2,7 @@ --- -# Ի՞նչ է հետևյալ ԵՎ-ով արտահայտության արդյունքը: +# Ի՞նչ է հետևյալ ԵՎ-ով արտահայտության արդյունքը Ի՞նչ կտպի ներքևում գրված ծրագիրը։ 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 edeef4b1c..dcc5ee0ff 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,7 +2,7 @@ --- -# Ի՞նչ է հետևյալ ԵՎ-ով և ԿԱՄ֊ով արտահայտության արդյունքը: +# Ի՞նչ է հետևյալ ԵՎ-ով և ԿԱՄ֊ով արտահայտության արդյունքը Ի՞նչ կտպի ներքևում գրված ծրագիրը։ 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 090636ebe..c025cd8c6 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 @@ --- -# Check the range between +# Միջակայքի ստուգում -Write an `if` condition to check that `age` is between `14` and `90` inclusively. +Գրեք `if` պայման, որը կստուգի արդյոք `age` փոփոխականը ընկած է `14` և `90` թվերի միջակայքում, այդ թվերը ներառյալ։ -"Inclusively" means that `age` can reach the edges `14` or `90`. +"Ներառյալ" նշանակում է, որ `age`֊ը կարող է ընդունել `14` կամ `90` արժեքները նույնպես։ From 7b2e8c7dc841a8674c4781839015e8edfa5fc859 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 6 Aug 2021 22:00:37 +0400 Subject: [PATCH 13/26] 7-check-if-out-range translated --- .../11-logical-operators/7-check-if-out-range/solution.md | 4 ++-- .../11-logical-operators/7-check-if-out-range/task.md | 6 +++--- 2 files changed, 5 insertions(+), 5 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..11e9b2a9d 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: +Առաջին եղանակը․ ```js if (!(age >= 14 && age <= 90)) ``` -The second variant: +Երկրորդ եղանակը․ ```js if (age < 14 || age > 90) 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 447a315ae..698f9bce4 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 @@ --- -# Check the range outside +# Միջակայքից դուրս ստուգում -Write an `if` condition to check that `age` is NOT between `14` and `90` inclusively. +Գրեք `if` պայման, որը կստուգի արդյոք `age` փոփոխականը ընկած ՉԷ `14` և `90` թվերի միջակայքում, այդ թվերը ներառյալ։ -Create two variants: the first one using NOT `!`, the second one -- without it. +Խնդրիը լուծեք երկու եղանակով․ առաջինը օգտագործելով ՈՉ `!` օպերատորը, երկրորդը առանց ՈՉ֊ի։ From ccc824f7378e3433bf40c8b7e996981aafc998e1 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 6 Aug 2021 22:11:20 +0400 Subject: [PATCH 14/26] 8-if-question translated --- .../8-if-question/solution.md | 24 +++++++++---------- .../8-if-question/task.md | 12 +++++----- 2 files changed, 18 insertions(+), 18 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..e57f03e99 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. +Պատասխան՝ առաջին և երրորդ `alert`֊ները կկանչվեն։ -Details: +Մանրամասներ․ ```js run -// Runs. -// The result of -1 || 0 = -1, truthy -if (-1 || 0) alert( 'first' ); +// Կանչվում է, +// քանի որ -1 || 0 = -1 ճշմարիտ է +if (-1 || 0) alert('առաջին') -// Doesn't run -// -1 && 0 = 0, falsy -if (-1 && 0) alert( 'second' ); +// Չի կանչվում, +// քանի որ -1 && 0 = 0 սխալական է +if (-1 && 0) alert('երկրորդ') -// Executes -// Operator && has a higher precedence than || -// so -1 && 1 executes first, giving us the chain: +// Կնչվում է, քանի որ +// && օպերատորի նախապատվությունը ավելի բարձր է, քան ||֊ինը, +// այսպիսով -1 && 1 հաշվվում է առաջինը։ Ստանում ենք հետևյալ շղթան․ // null || -1 && 1 -> null || 1 -> 1 -if (null || -1 && 1) alert( 'third' ); +if (null || -1 && 1) alert('երրորդ') ``` 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 5f9812e86..7be8bb7d2 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,14 +2,14 @@ --- -# A question about "if" +# Հարց "if"֊ի մասին -Which of these `alert`s are going to execute? +Այս `alert`֊ներից որո՞նք կաշխատեն։ -What will the results of the expressions be inside `if(...)`? +Ի՞նչ կլինի `if(...)`֊երի ներսում գրված արտահայտությունների արժեքները։ ```js -if (-1 || 0) alert('first') -if (-1 && 0) alert('second') -if (null || (-1 && 1)) alert('third') +if (-1 || 0) alert('առաջին') +if (-1 && 0) alert('երկրորդ') +if (null || -1 && 1) alert('երրորդ') ``` From 1bb3af52a38282b4033ad322cae5488db2e25dd1 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 6 Aug 2021 23:12:04 +0400 Subject: [PATCH 15/26] start translating 9-check-login --- .../11-logical-operators/9-check-login/ifelse_task.svg | 2 +- 1-js/02-first-steps/11-logical-operators/9-check-login/task.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 ca3e0aead..32a9fc53f 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 +ՍկիզբՉեղարկված էՉեղարկված էԲարի գալուստՉեմ ճանաչում քեզՍխալ գաղտնաբառՈ՞վ էԳաղտնաբառը՞ՉեղարկելՉեղարկելԱդմինTheMasterՈւրիշՈւրիշ \ No newline at end of file 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 8645bdff2..71867007e 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,7 +2,7 @@ --- -# Check the login +# Մուտքի ստուգում (login) Write the code which asks for a login with `prompt`. From 61801fdc66c5ff93407d195633fd66d3be3895cd Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Sat, 7 Aug 2021 01:03:52 +0400 Subject: [PATCH 16/26] 9-check-login translated --- .../9-check-login/ifelse_task.svg | 207 +++++++++++++++++- .../9-check-login/solution.md | 20 +- .../9-check-login/task.md | 18 +- 3 files changed, 225 insertions(+), 20 deletions(-) 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 79a98ebef..148b4cdab 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,206 @@ -ՍկիզբՉեղարկված էՉեղարկված էԲարի գալուստՉեմ ճանաչում քեզՍխալ գաղտնաբառՈ՞վ էԳաղտնաբառը՞ՉեղարկելՉեղարկելԱդմինԳլխավորՈւրիշՈւրիշ \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 604606259..68a51b0ee 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("Ո՞վ է", ''); -if (userName === 'Admin') { +if (userName === 'Ադմին') { - let pass = prompt('Password?', ''); + let pass = prompt('Գաղտնաբառը՞', ''); - if (pass === 'TheMaster') { - alert( 'Welcome!' ); + if (pass === 'Գլխավոր') { + alert( 'Բարի գալուստ' ); } else if (pass === '' || pass === null) { - alert( 'Canceled' ); + alert( 'Չեղարկված է' ); } else { - alert( 'Wrong password' ); + alert( 'Սխալ գաղտնաբառ' ); } } else if (userName === '' || userName === null) { - alert( 'Canceled' ); + alert( 'Չեղարկված է' ); } else { - alert( "I don't know you" ); + alert( "Չեմ ճանաչում քեզ" ); } ``` -Note the vertical indents inside the `if` blocks. They are technically not required, but make the code more readable. +Ուշադրություն դարձրեք ուղղահայաց խորություններին(indents) `if` բլոկների ներսում։ Դրանք պարտադիր չեն, բայց դարձնում են ծրագիրը ավելի ընոեռնելի։ 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 71867007e..eb3a7f2e8 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 @@ -4,22 +4,22 @@ # Մուտքի ստուգում (login) -Write the code which asks for a login with `prompt`. +Գրեք ծրագիր, որը կպահանջի մուտքի օգտագործելով `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". +Եթե օգտատերը կմուտքագրի `"Ադմին"`, ապա կբացվի `prompt` գաղտնաբառի համար, եթե ոչինչ չմուտքագրի կամ սեղմի `Esc` ստեղնը -- կցուցադրվի "Չեղարկված է", եթե մեկ այլ տողային արժեք մուտքագրվի, ապա կցուցադրվի "Չեմ ճանաչում քեզ"։ -The password is checked as follows: +Գաղտնաբառը ստուգվում է հետևյալ կերպ․ -- If it equals "TheMaster", then show "Welcome!", -- Another string -- show "Wrong password", -- For an empty string or cancelled input, show "Canceled" +- Եթե այն "Գլխավոր" է, ապա ցուցադրվում է "Բարի գալուստ", +- Ուրիշ տողային արժեքի դեպքում ցուցադրվում է "Սխալ գաղտնաբառ", +- Դատարի տողի և չեղարկված(cancelled) դեպքերում ցուցադրվում է "Չեղարկված է" -The schema: +Գծապատկերը․ ![](ifelse_task.svg) -Please use nested `if` blocks. Mind the overall readability of the code. +Օգտագործել ներդրված `if` բլոկներ։ Հիշեք նաև ծրագրի ընթեռնելիության մասին։ -Hint: passing an empty input to a prompt returns an empty string `''`. Pressing `key:ESC` during a prompt returns `null`. +Հուշում․ prompt֊ին դատարկ տողային արժեք փոխանցելիս այն վերադարձնում է `''`։ `Esc` ստեղնը սեղմելիս prompt֊ի վրա, այն վերադարձնում է `null`։ [demo] From fe68296f4cce043a93c661aff943331fb7691aa6 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Wed, 11 Aug 2021 22:57:51 +0400 Subject: [PATCH 17/26] translation bugfixes in logical operators --- .../1-alert-null-2-undefined/solution.md | 2 +- .../1-alert-null-2-undefined/task.md | 4 +- .../2-alert-or/solution.md | 8 +- .../11-logical-operators/2-alert-or/task.md | 4 +- .../3-alert-1-null-2/solution.md | 2 +- .../3-alert-1-null-2/task.md | 4 +- .../4-alert-and/solution.md | 2 +- .../11-logical-operators/4-alert-and/task.md | 4 +- .../5-alert-and-or/task.md | 2 +- .../6-check-if-in-range/task.md | 2 +- .../7-check-if-out-range/task.md | 2 +- .../8-if-question/task.md | 2 +- .../9-check-login/ifelse_task.svg | 207 +----------------- .../9-check-login/solution.md | 2 +- .../9-check-login/task.md | 6 +- .../11-logical-operators/article.md | 103 +++++---- 16 files changed, 74 insertions(+), 282 deletions(-) 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 478586635..99bc1d5e2 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,5 +1,5 @@ Պատասխանը `2` է, քանի որ այն առաջին ճշմարիտ արժեքն է։ ```js run -alert(null || 2 || undefined) +alert( null || 2 || undefined ); ``` 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 27b63d235..27e56f58b 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 @@ -1,4 +1,4 @@ -Կարևորություն: 5 +importance: 5 --- @@ -7,5 +7,5 @@ Ի՞նչ կտպի ներքևում գրված ծրագիրը։ ```js -alert(null || 2 || undefined) +alert( null || 2 || undefined ); ``` 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 e8aa3387a..a06dd4d88 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 @@ Այն կտպի `1`, այնուհետև `2`։ ```js run -alert(alert(1) || 2 || alert(3)) +alert( alert(1) || 2 || alert(3) ); ``` -`alert`֊ի կանչը չի վերադարձնում ոչ մի արժեք։ Կամ այլ կերպա ասած վերադարձնում է `undefined`։ +`alert`֊ի կանչը չի վերադարձնում ոչ մի արժեք։ Կամ այլ կերպ ասած վերադարձնում է `undefined`։ -1. Սկզբում ԿԱՄ `||`֊ը հաշվում(evaluates) է իր ձախ կողմի օպերանդը՝ `alert(1)`, որն էլ էկրանին ցույց է տալիս `1` արժեքը։ +1. Սկզբում ԿԱՄ `||`֊ը հաշվում (evaluates) է իր ձախ կողմի օպերանդը՝ `alert(1)`, որն էլ էկրանին ցույց է տալիս `1` արժեքը։ 2. `alert`֊ը վերադարձնում է `undefined`։ ԿԱՄ֊ը անցնում է երկրորդ օպերանդին՝ որոնելով ճշմարիտ արժեք։ -3. Երկրորդ օպերանդը `2` է, որը ճշմարիտ է, և ԿԱՄ֊ը դադարացնում է իր հաշվարկները։ `2`֊ը վերադարձվում է և ցուցադրվում էկրանին դրսի `alert`֊ի միջոցով։ +3. Երկրորդ օպերանդը `2` է, որը ճշմարիտ է, և ԿԱՄ֊ը դադարեցնում է իր հաշվարկները։ `2`֊ը վերադարձվում է և ցուցադրվում էկրանին դրսի `alert`֊ի միջոցով։ `3`֊ը չի երևա էկրանին, քանի որ ԿԱՄ֊ը կանգ է առնում երկրորդ օպերանդի վրա և չի հասնում `alert(3)`֊ին։ 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 bf4578517..3bcfcea8b 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 @@ -1,4 +1,4 @@ -Կարևորություն: 3 +importance: 3 --- @@ -7,5 +7,5 @@ Ի՞նչ կտպի ներքևում գրված ծրագիրը։ ```js -alert(alert(1) || 2 || alert(3)) +alert( alert(1) || 2 || alert(3) ); ``` 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 832e2cede..7ea607ed1 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,6 +1,6 @@ Պատասխանը `null` է, քանի որ այն առաջին սխալական արժեքն է։ ```js run -alert(1 && null && 2) +alert( 1 && null && 2 ); ``` 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 2c3458af3..e46adfb69 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 @@ -1,4 +1,4 @@ -Կարևորություն: 5 +importance: 5 --- @@ -7,5 +7,5 @@ Ի՞նչ կտպի ներքևում գրված ծրագիրը։ ```js -alert(1 && null && 2) +alert( 1 && null && 2 ); ``` 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 f6dad7201..ac1846ec0 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,7 +1,7 @@ Այն կտպի `1`, այնուհետև `undefined`։ ```js run -alert(alert(1) && alert(2)); +alert( alert(1) && alert(2) ); ``` `alert`֊ի կանչը տպում է էկրանին և վերադարձնում `undefined`։ 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 8b64e2636..aa31c87fa 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 @@ -1,4 +1,4 @@ -Կարևորություն: 3 +importance: 3 --- @@ -7,5 +7,5 @@ Ի՞նչ կտպի ներքևում գրված ծրագիրը։ ```js -alert(alert(1) && alert(2)) +alert( alert(1) && alert(2) ); ``` 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 dcc5ee0ff..3ce663f1f 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 @@ -1,4 +1,4 @@ -Կարևորություն: 5 +importance: 5 --- 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 c025cd8c6..2ca505d31 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 @@ -1,4 +1,4 @@ -Կարևորություն: 3 +importance: 3 --- 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 698f9bce4..86aca175f 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 @@ -1,4 +1,4 @@ -Կարևորություն: 3 +importance: 3 --- 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 7be8bb7d2..24dc9d396 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 @@ -1,4 +1,4 @@ -Կարևորություն: 5 +importance: 5 --- 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 148b4cdab..020126cb8 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,206 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +ՍկիզբՉեղարկված էՉեղարկված էԲարի գալուստՉեմ ճանաչում քեզՍխալ գաղտնաբառՈ՞վ էԳաղտնաբառը՞ՉեղարկելՉեղարկելԱդմինԳլխավորՈւրիշՈւրիշ \ No newline at end of file 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 68a51b0ee..26c628d12 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 @@ -22,4 +22,4 @@ if (userName === 'Ադմին') { } ``` -Ուշադրություն դարձրեք ուղղահայաց խորություններին(indents) `if` բլոկների ներսում։ Դրանք պարտադիր չեն, բայց դարձնում են ծրագիրը ավելի ընոեռնելի։ +Ուշադրություն դարձրեք ուղղահայաց խորություններին (indents) `if` բլոկների ներսում։ Դրանք պարտադիր չեն, բայց դարձնում են ծրագիրը ավելի ընթեռնելի։ 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 eb3a7f2e8..a02b60d84 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 @@ -1,10 +1,10 @@ -Կարևորություն: 3 +importance: 3 --- # Մուտքի ստուգում (login) -Գրեք ծրագիր, որը կպահանջի մուտքի օգտագործելով `prompt`֊ը։ +Գրեք ծրագիր, որը կպահանջի մուտք գործել, օգտագործելով `prompt`֊ը։ Եթե օգտատերը կմուտքագրի `"Ադմին"`, ապա կբացվի `prompt` գաղտնաբառի համար, եթե ոչինչ չմուտքագրի կամ սեղմի `Esc` ստեղնը -- կցուցադրվի "Չեղարկված է", եթե մեկ այլ տողային արժեք մուտքագրվի, ապա կցուցադրվի "Չեմ ճանաչում քեզ"։ @@ -12,7 +12,7 @@ - Եթե այն "Գլխավոր" է, ապա ցուցադրվում է "Բարի գալուստ", - Ուրիշ տողային արժեքի դեպքում ցուցադրվում է "Սխալ գաղտնաբառ", -- Դատարի տողի և չեղարկված(cancelled) դեպքերում ցուցադրվում է "Չեղարկված է" +- Դատարկ տողի և չեղարկված (cancelled) դեպքերում ցուցադրվում է "Չեղարկված է" Գծապատկերը․ 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 7b28b0932..968717970 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -1,8 +1,8 @@ # Տրամաբանական օպերատորներ (Logical operators) -JavaScript-ում կան չորս տրամաբանական օպերատորներ՝ `||` (ԿԱՄ), `&&` (ԵՎ), `!` (ՈՉ), `??` (Null-ի հետ համակցման). Այստեղ մենք կծանոթանանք առաջին երեքին։ `??` օպերատորին կարող եք ծանոթանալ հաջորդ հոդվածում։ +JavaScript-ում կան չորս տրամաբանական օպերատորներ՝ `||` (ԿԱՄ), `&&` (ԵՎ), `!` (ՈՉ), `??` (Nullish Coalescing). Այստեղ մենք կծանոթանանք առաջին երեքին։ `??` օպերատորին կարող եք ծանոթանալ հաջորդ հոդվածում։ -Չնայած նրանք անվանվում են "տրամաբանական", նրանք կարող են կիրառվել կամայական(տարբերվող տրամաբանական տիպից) տիպի վրա։ Նրանց արդյունքը նույպես կարող է լինել կամայական տիպի։ +Չնայած նրանք անվանվում են "տրամաբանական", նրանք կարող են կիրառվել կամայական (տարբերվող տրամաբանական տիպից) տիպի վրա։ Նրանց արդյունքը նույպես կարող է լինել կամայական տիպի։ Եկեք դիտարկենք ավելի մանրամասն։ @@ -14,33 +14,32 @@ JavaScript-ում կան չորս տրամաբանական օպերատորնե result = a || b ``` -Դասական ծրագրավորման մեջ տրամաբանական ԿԱՄ օպերատորը կիրառվում է միայն տրամաբանական արժեքների վրա։ Եթե նրա արգումենտներից մեկը ճշմարի `true` է, ապա այն վերադարձնում է `true`, հակառակ դեպքում՝ `false`։ +Դասական ծրագրավորման մեջ տրամաբանական ԿԱՄ օպերատորը կիրառվում է միայն տրամաբանական արժեքների վրա։ Եթե նրա արգումենտներից մեկը ճշմարիտ `true` է, ապա այն վերադարձնում է `true`, հակառակ դեպքում՝ `false`։ JavaScript֊ում այս օպերատորը ավելի ճկուն և հզոր է։ Բայց սկզում եկեք տեսնենք, թե ինչ է կատարվում տրամաբանական տիպերի հետ։ Կան չորս տրամաբանական կոմբինայիաներ․ ```js run -alert(true || true) // true -alert(false || true) // true -alert(true || false) // true -alert(false || false) // false +alert( true || true ); // true +alert( false || true ); // true +alert( true || false ); // true +alert( false || false ); // false ``` -Ինչպես տեսնում ենք արդյունքը միշտ ճիշտ(`true`) է, բացի այն դեպքից, երբ երկու օպերանդներն էլ սխալ(`false`) են։ +Ինչպես տեսնում ենք արդյունքը միշտ ճիշտ (`true`) է, բացի այն դեպքից, երբ երկու օպերանդներն էլ սխալ (`false`) են։ -Եթե օպերանդը տրամաբանական տիպ չի, ապա այն փոխակերպվում(convert) է տրամաբանական տիպի։ +Եթե օպերանդը տրամաբանական տիպ չի, ապա այն փոխակերպվում (convert) է տրամաբանական տիպի։ Օրինակ `1`֊ը մշակվում է որպես `true`, `0`֊ն՝ `false`․ ```js run -if (1 || 0) { - // աշխատում է ինչպես if( true || false ) +if (1 || 0) { // աշխատում է ինչպես if( true || false ) alert('Ճշմարիտ է!') } ``` -Շատ հաճախ ԿԱՄ `||` օպերատորը օգտագործվում է `if` պայմանի օպերատորի հետ՝ ստուգելու համար արդյոք ճիշտ(`true`) է տրված պայմաններից _գոնե մեկը_։ +Շատ հաճախ ԿԱՄ `||` օպերատորը օգտագործվում է `if` պայմանի օպերատորի հետ՝ ստուգելու համար արդյոք ճիշտ (`true`) է տրված պայմաններից _գոնե մեկը_։ Օրինակ․ @@ -83,7 +82,7 @@ result = value1 || value2 || value3 - Ամեն օպերանդի արժեք փոխակերպում է տրամաբանական տիպի։ Եթե արդյունքը `true` է այն կանգ է առնում և վերադարձնում այդ օպերանդի օրիգինալ արժեքը։ - Եթե բոլոր օպերանդները հաշվվում են, և բոլորի արժեքը `false` է լինում, ապա վերադարձնում է վերջին օպերանդի արժեքը։ -Արժեքը վերադարձվում է իր օրիգինալ վիճակում, առանց փոխարկման(conversion)։ +Արժեքը վերադարձվում է իր օրիգինալ վիճակում, առանց փոխարկման (conversion)։ Այլ կերպ ասած, ԿԱՄ `||`֊երից կազմված շղթան վերադարձնում է առաջին ճշմարիտ արժեքը, կամ վերջինը, եթե չկան ճշմարիտ արժեքներ։ @@ -95,47 +94,47 @@ alert(1 || 0) // 1 (1֊ը ճշմարիտ է) alert(null || 1) // 1 (1֊ը առաջին ճշմարիտ արժեքն է) alert(null || 0 || 1) // 1 (առաջին ճշմարիտ արժեքը) -alert(undefined || null || 0) // 0 (քանի որ բոլորը սխալական(falsy) են, վերադարձնում է վերջինը) +alert(undefined || null || 0) // 0 (քանի որ բոլորը սխալական (falsy) են, վերադարձնում է վերջինը) ``` Սա հնարավորություն է տալիս կիրառել օպերատորը "մաքուր, ստանդարտ, միայն տրամաբանական ԿԱՄ"֊ի շրջանակներից դուրս։ 1. **Առաջին ճշմարիտ արժեքի ստացումը փոփոխականների կամ արտահայտությունների ցուցակից։** - Օրինակի, ունենք `firstName`, `lastName` և `nickName` փոփոխականները, բոլորը ըստ ցանկության կարող են ստանալ սխալական կամ `undefined` արժեքներ։ + Օրինակ ունենք `firstName`, `lastName` և `nickName` փոփոխականները, բոլորը ըստ ցանկության կարող են ստանալ սխալական կամ `undefined` արժեքներ։ - Եկեք օգտագործենք ԿԱՄ `||`֊ը ընտրելու համար մեկը որը ունի արժեք(ճշմարիտ) և ցույց տանք այն (կամ `"Anonymous"` եթե այդպիսի արժեք չի գտնվել)։ + Եկեք օգտագործենք ԿԱՄ `||`֊ը ընտրելու համար մեկը որը ունի արժեք (ճշմարիտ) և ցույց տանք այն (կամ `"Anonymous"` եթե այդպիսի արժեք չի գտնվել)։ - ```js run - let firstName = ""; - let lastName = ""; - let nickName = "SuperCoder"; + ```js run + let firstName = ""; + let lastName = ""; + let nickName = "SuperCoder"; - *!* - alert( firstName || lastName || nickName || "Anonymous"); // SuperCoder - */!* - ``` + *!* + alert( firstName || lastName || nickName || "Anonymous"); // SuperCoder + */!* + ``` - Եթե բոլոր փոփոխականները լինեին սխալական, ապա կտեսնեինք `"Anonymous"`։ + Եթե բոլոր փոփոխականները լինեին սխալական, ապա կտեսնեինք `"Anonymous"`։ 2. **Կրճատ հաշվարկ (Short-circuit evaluation)։** - ԿԱՄ `||`֊ի մեկ այլ հատկությունը այսպես կոչված "կրճատ հաշվարկ"֊ի հատկությունն է։ + ԿԱՄ `||`֊ի մեկ այլ հատկությունը այսպես կոչված "կրճատ հաշվարկ"֊ի հատկությունն է։ - Դա նշանակում է, որ `||`֊ը կատարում է իր արգումենտների հաշվարկը և փոխակերպումը տրամաբանական տիպի մինչև առաջին ճշմարիտ արժեքին հանդիպելը, ապա այդ արժեքը միանգամից վերադարձվում է, առանց նույնիսկ հաջորդ արգումենտներին նայելու։ + Դա նշանակում է, որ `||`֊ը կատարում է իր արգումենտների հաշվարկը և փոխակերպումը տրամաբանական տիպի մինչև առաջին ճշմարիտ արժեքին հանդիպելը, ապա այդ արժեքը միանգամից վերադարձվում է, առանց նույնիսկ հաջորդ արգումենտներին նայելու։ - Այս հատկության կարևորությունն ակնհայտ է դառնում, եթե օպերանդը պարզապես արժեք չէ, այլ ինչ֊որ արտահայտություն՝ կողմնակի ազդեցությամբ, օրինակ փոփոխականի վերագրում կամ ֆունկցիայի կանչ։ + Այս հատկության կարևորությունն ակնհայտ է դառնում, եթե օպերանդը պարզապես արժեք չէ, այլ ինչ֊որ արտահայտություն՝ կողմնակի ազդեցությամբ, օրինակ փոփոխականի վերագրում կամ ֆունկցիայի կանչ։ - Ներքևի օրինակում միայն երկրորդ նամակը կերևա էկրանին․ + Ներքևի օրինակում միայն երկրորդ նամակը կերևա էկրանին․ - ```js run no-beautify - *!*true*/!* || alert("չի երևա"); - *!*false*/!* || alert("կերևա"); - ``` + ```js run no-beautify + *!*true*/!* || alert("չի երևա"); + *!*false*/!* || alert("կերևա"); + ``` - Առաջին տողում ԿԱՄ `||` օպերատորը անմիջապես դադարեցնում է հաշվարկը հենց հանդիպում է `true` արժեքին, այդ պատճառով `alert`֊ը չի կանչվում։ + Առաջին տողում ԿԱՄ `||` օպերատորը անմիջապես դադարեցնում է հաշվարկը հենց հանդիպում է `true` արժեքին, այդ պատճառով `alert`֊ը չի կանչվում։ - Հաճախ ծրագրավորողները օգտագործում են այս հատկությունը այն դեպքում, երբ անհրաժեշտ է կատարել հրամանները(execute commands) այն և միայն այն դեպքում, երբ ձախ կողմի գրված պայմանը սխալական է։ + Հաճախ ծրագրավորողները օգտագործում են այս հատկությունը այն դեպքում, երբ անհրաժեշտ է կատարել հրամանները (execute commands) այն և միայն այն դեպքում, երբ ձախ կողմի գրված պայմանը սխալական է։ ## && (ԵՎ) (AND) @@ -148,10 +147,10 @@ result = a && b Դասական ծրագրավորման մեջ ԵՎ օպերատորը վերադարձնում է `true`, եթե իր երկու օպերանդների արժեքները ճշմերիտ են, հակառակ դեպքում՝ `false`։ ```js run -alert(true && true) // true -alert(false && true) // false -alert(true && false) // false -alert(false && false) // false +alert( true && true ); // true +alert( false && true ); // false +alert( true && false ); // false +alert( false && false ); // false ``` Օրինակ `if`֊ի հետ։ @@ -168,8 +167,7 @@ if (hour == 12 && minute == 30) { Ինչպես ԿԱՄ֊ի դեպքում, ԵՎ֊ի օպերանդները նույնպես կարող են ունենալ կամայական արժեք․ ```js run -if (1 && 0) { - // հաշվվում է ինչպես true && false +if (1 && 0) { // հաշվվում է ինչպես true && false alert('չի երևա, որովհետև արժեքը սխալական է') } ``` @@ -188,7 +186,7 @@ result = value1 && value2 && value3 - Ամեն օպերանդի արժեք փոխակերպում է տրամաբանական տիպի։ Եթե արդյունքը `false` է այն կանգ է առնում և վերադարձնում այդ օպերանդի օրիգինալ արժեքը։ - Եթե բոլոր օպերանդները հաշվվում են, և բոլորի արժեքը `true` է լինում, ապա վերադարձնում է վերջին օպերանդի արժեքը։ -In other words, AND returns the first falsy value or the last value if none were found. +Այլ կերպ ասած, ԵՎ֊ը վերադարձնում է առաջին սխալական արժեքը, կամ վերջին արժեքը, եթե ոչ մի սխալական արժեք չի գտնվել։ Վերոնշյալ կանոնները նման են ԿԱՄ֊ին։ Տարբերությունն այն է, որ ԵՎ֊ը վերադարձնում է առաջին _սխալական_ արժեքը, իսկ ԿԱՄ֊ը՝ առաջին _ճշմարիտ_ արժեքը։ @@ -201,8 +199,7 @@ alert(1 && 0) // 0 alert(1 && 5) // 5 // Եթե առաջին օպերանդը սխալական է, -// ապա ԵՎ֊ը վերադարձնում է այն։ -// Երկրորդ օպերանդը անտեսվում է։ +// ապա ԵՎ֊ը վերադարձնում է այն։ Երկրորդ օպերանդը անտեսվում է։ alert(null && 5) // null alert(0 && 'կապ չունի ինչ') // 0 ``` @@ -219,11 +216,11 @@ alert(1 && 2 && null && 3) // null alert(1 && 2 && 3) // 3, վերջինը ``` -````smart header="ԵՎ `&&`֊ի նախապատվությունը(precedence) ավելի բարձր է քան ԿԱՄ `||`֊ինը" +````smart header="ԵՎ `&&`֊ի նախապատվությունը (precedence) ավելի բարձր է քան ԿԱՄ `||`֊ինը" Այսպիսով `a && b || c && d` արտահայտությունը համարժեք է հետևյալ արտահայտությանը՝ `(a && b) || (c && d)`, որտեղ `&&`֊երը փակագծերի մեջ են։ -````` +```` ````warn header="Մի փոխարինեք `if`֊ը `||`֊ով կամ `&&`֊ով" Հաճախ ծրագրավորողները օգտագործում են ԵՎ `&&` օպերատորը, որպես "`if`֊ի կարճ գրելաձև"։ @@ -236,7 +233,7 @@ let x = 1; (x > 0) && alert('Մեծ է զրոից'); ``` -Աջ կողմի գործողությունը կկատարվի այն ժամանակ, երբ ձախից աջ արժեքավրումը հասնի իրեն(այսինքն ձախ կողմի բոլոր արժեքները ճշմարիտ են)։ Դա տեղի կունենա, եթե `(x > 0)` արտահայտությունը ճիշտ լինի։ +Աջ կողմի գործողությունը կկատարվի այն ժամանակ, երբ ձախից աջ արժեքավորումը հասնի իրեն (այսինքն ձախ կողմի բոլոր արժեքները ճշմարիտ են)։ Դա տեղի կունենա, եթե `(x > 0)` արտահայտությունը ճիշտ լինի։ Դա ստացվում է հետևյալի անալոգը․ @@ -247,19 +244,19 @@ if (x > 0) alert('Մեծ է զրոից'); ``` Թեև `&&`֊ով տարբերակն ավելի կարճ է, `if`֊ը ավելի հասկանալի է և ավելի ընթեռնելի։ Այսպիսով, մենք խորհուրդ ենք տալիս օգտագործել յուրաքանչյուր գրելաձև իր նշանակությանը համապատասխան՝ օգտագործեք `if` եթե ցանկանում եք պայման ստուգել, և `&&`, եթե ցանկանում եք կատարել ԵՎ տրամաբանական գործողությունը։ -````` +```` ## ! (ՈՉ) (NOT) Տրամաբանական ՈՉ օպերատորը ներկայացվում է բացականչական նշանի միջոցով՝ `!`։ -Նրա շարահյուսությունը(syntax) շատ պարզ է․ +Նրա շարահյուսությունը (syntax) շատ պարզ է․ ```js result = !value ``` -Օպերատորը ընդունում է մեկ արգումենտ է կատարում հետևյալ քայլերը․ +Օպերատորը ընդունում է մեկ արգումենտ և կատարում հետևյալ քայլերը․ 1. Փոխակերպում է օպերանդը տրամաբանական տիպի՝ `true/false`. 2. Վերադարձնում է հակադարձ արժեքը։ @@ -267,8 +264,8 @@ result = !value Օրինակ․ ```js run -alert(!true) // false -alert(!0) // true +alert( !true ); // false +alert( !0 ); // true ``` Երբեմն կրկնակի ՈՉ `!!`֊ը օգտագործվում է արժեքը տրամաբանական տիպի փոխակերպելու համար․ @@ -278,7 +275,7 @@ alert(!!'ոչ դատարկ տողային արժեք') // true alert(!!null) // false ``` -Այսինքն՝ առաջին ՈՉ֊ը փոխակերպում է արժեքը տրամաբանական տիպի, և վերադարձնում դրա հակադարձը, իսկ երկրորդ ՈՉ֊ը կրկին հակադարձում է այն։ Վերջնարդյունքում ունենում ենք տրամաբանական տիպի փոխակերպում(value-to-boolean conversion)։ +Այսինքն՝ առաջին ՈՉ֊ը փոխակերպում է արժեքը տրամաբանական տիպի, և վերադարձնում դրա հակադարձը, իսկ երկրորդ ՈՉ֊ը կրկին հակադարձում է այն։ Վերջնարդյունքում ունենում ենք տրամաբանական տիպի փոխակերպում (value-to-boolean conversion)։ Այս գործողության ավելի տեսանելի տարբերակը ներկառուցված `Boolean` ֆունկցիայի կիրառմամբ է․ From 1f1ea7ddd12b79e8b3ae28b7c07948155e575889 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 13 Aug 2021 20:08:18 +0400 Subject: [PATCH 18/26] Update 1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/solution.md Co-authored-by: Arsen Melikyan --- .../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 7ea607ed1..6af9bdde5 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,6 +1,6 @@ Պատասխանը `null` է, քանի որ այն առաջին սխալական արժեքն է։ ```js run -alert( 1 && null && 2 ); +alert( 1 && null && 2 ); ``` From 87442eb06c704ffd014dcdfadae71bf2f942071d Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 13 Aug 2021 20:08:39 +0400 Subject: [PATCH 19/26] Update 1-js/02-first-steps/11-logical-operators/4-alert-and/task.md Co-authored-by: Arsen Melikyan --- 1-js/02-first-steps/11-logical-operators/4-alert-and/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 aa31c87fa..7b758dbe5 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 @@ -7,5 +7,5 @@ importance: 3 Ի՞նչ կտպի ներքևում գրված ծրագիրը։ ```js -alert( alert(1) && alert(2) ); +alert( alert(1) && alert(2) ); ``` From 8b25f3bd338006028411a8b0baa90808685bcd4b Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 13 Aug 2021 20:08:53 +0400 Subject: [PATCH 20/26] Update 1-js/02-first-steps/11-logical-operators/article.md Co-authored-by: Arsen Melikyan --- 1-js/02-first-steps/11-logical-operators/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 968717970..a05d8669b 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -11,7 +11,7 @@ JavaScript-ում կան չորս տրամաբանական օպերատորնե "ԿԱՄ" օպերատորը ներկայացվում է երկու ուղղահայաց գիծ նշանների միջոցով։ ```js -result = a || b +result = a || b; ``` Դասական ծրագրավորման մեջ տրամաբանական ԿԱՄ օպերատորը կիրառվում է միայն տրամաբանական արժեքների վրա։ Եթե նրա արգումենտներից մեկը ճշմարիտ `true` է, ապա այն վերադարձնում է `true`, հակառակ դեպքում՝ `false`։ From dab480512a1c78275d3a78a9548cfc587c563831 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 13 Aug 2021 20:09:04 +0400 Subject: [PATCH 21/26] Update 1-js/02-first-steps/11-logical-operators/article.md Co-authored-by: Arsen Melikyan --- 1-js/02-first-steps/11-logical-operators/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a05d8669b..5a94f2cf6 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -160,7 +160,7 @@ let hour = 12 let minute = 30 if (hour == 12 && minute == 30) { - alert('Ժամը 12։30֊ն է') + alert('Ժամը 12։30֊ն է'); } ``` From 34f33333debc8852aebee73237cbd2041e897b58 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 13 Aug 2021 20:09:13 +0400 Subject: [PATCH 22/26] Update 1-js/02-first-steps/11-logical-operators/article.md Co-authored-by: Arsen Melikyan --- 1-js/02-first-steps/11-logical-operators/article.md | 4 ++-- 1 file changed, 2 insertions(+), 2 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 5a94f2cf6..44437fc36 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -156,8 +156,8 @@ alert( false && false ); // false Օրինակ `if`֊ի հետ։ ```js run -let hour = 12 -let minute = 30 +let hour = 12; +let minute = 30; if (hour == 12 && minute == 30) { alert('Ժամը 12։30֊ն է'); From dde7793e379c7ad4b3655fe60049fa0c3df9cf14 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 13 Aug 2021 20:09:26 +0400 Subject: [PATCH 23/26] Update 1-js/02-first-steps/11-logical-operators/article.md Co-authored-by: Arsen Melikyan --- 1-js/02-first-steps/11-logical-operators/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 44437fc36..d951fb9ca 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -168,7 +168,7 @@ if (hour == 12 && minute == 30) { ```js run if (1 && 0) { // հաշվվում է ինչպես true && false - alert('չի երևա, որովհետև արժեքը սխալական է') + alert('չի երևա, որովհետև արժեքը սխալական է'); } ``` From a12a35c67f27825d7cc592500f6084c68ede1fe0 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 13 Aug 2021 20:09:36 +0400 Subject: [PATCH 24/26] Update 1-js/02-first-steps/11-logical-operators/article.md Co-authored-by: Arsen Melikyan --- 1-js/02-first-steps/11-logical-operators/article.md | 4 ++-- 1 file changed, 2 insertions(+), 2 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 d951fb9ca..70b0ee042 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -195,8 +195,8 @@ result = value1 && value2 && value3 ```js run // Եթե առաջին օպերանդը ճշմարիտ է, // ապա ԵՎ֊ը վերադարձնում է երկրոդ օպերանդը։ -alert(1 && 0) // 0 -alert(1 && 5) // 5 +alert( 1 && 0 ); // 0 +alert( 1 && 5 ); // 5 // Եթե առաջին օպերանդը սխալական է, // ապա ԵՎ֊ը վերադարձնում է այն։ Երկրորդ օպերանդը անտեսվում է։ From d85ba1b115de9fc06a5edefdb45ff05554654136 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 13 Aug 2021 20:09:54 +0400 Subject: [PATCH 25/26] Update 1-js/02-first-steps/11-logical-operators/article.md Co-authored-by: Arsen Melikyan --- 1-js/02-first-steps/11-logical-operators/article.md | 4 ++-- 1 file changed, 2 insertions(+), 2 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 70b0ee042..eba678852 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -200,8 +200,8 @@ alert( 1 && 5 ); // 5 // Եթե առաջին օպերանդը սխալական է, // ապա ԵՎ֊ը վերադարձնում է այն։ Երկրորդ օպերանդը անտեսվում է։ -alert(null && 5) // null -alert(0 && 'կապ չունի ինչ') // 0 +alert( null && 5 ); // null +alert( 0 && "կապ չունի ինչ" ); // 0 ``` Կարող ենք նաև մի քանի արժեք միաժամանակ փոխանցել։ Տեսնենք թե ինչպես է ԵՎ֊ը վերադարձնում առաջին սխալական արժեքը․ From a99cafda95386c6bdbc16bc869b5c00a602ce6c0 Mon Sep 17 00:00:00 2001 From: Vahagn Melkonyan Date: Fri, 13 Aug 2021 20:19:50 +0400 Subject: [PATCH 26/26] article fixed --- 1-js/02-first-steps/11-logical-operators/article.md | 2 ++ 1 file changed, 2 insertions(+) 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 eba678852..526882d12 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -172,6 +172,7 @@ if (1 && 0) { // հաշվվում է ինչպես true && false } ``` + ## ԵՎ "&&"֊ը գտնում է առաջին սխալական արժեքը Տրված է մի քանի արժեքներ կապակցված ԵՎ֊ով․ @@ -217,6 +218,7 @@ alert(1 && 2 && 3) // 3, վերջինը ``` ````smart header="ԵՎ `&&`֊ի նախապատվությունը (precedence) ավելի բարձր է քան ԿԱՄ `||`֊ինը" +ԵՎ `&&`֊ի նախապատվությունը (precedence) ավելի բարձր է քան ԿԱՄ `||`֊ինը: Այսպիսով `a && b || c && d` արտահայտությունը համարժեք է հետևյալ արտահայտությանը՝ `(a && b) || (c && d)`, որտեղ `&&`֊երը փակագծերի մեջ են։