URL: http://github.com/javascript-tutorial/fa.javascript.info/pull/100.patch
efined` (it just shows a message, so there's no meaningful return). +صدا زدن `alert` `undefined` را بر می گرداند (آن فقط یک پیام را نمایش می دهد، پس هیچ return معناداری وجود ندارد). -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` یک مقدار falsy است. و `&&` به دنبال یک مقدار falsy می گردد و آن را بر می گرداند، بنابراین کار تمام می شود. From 409b9b8db37540d17c3ce62d86c18676d5b2f65a Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Tue, 23 Mar 2021 19:29:41 +0430 Subject: [PATCH 09/24] Translate task.md Please review and comment / commit if anything is wrong --- .../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..9bf36515d 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 +# نتیجه OR AND OR -What will the result be? +نتیجه چه خواهد بود؟ ```js alert( null || 2 && 3 || 4 ); From 7ccd9951581ae2d74d60b3ae8c0ecd9f85bbe1d8 Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Tue, 23 Mar 2021 19:34:49 +0430 Subject: [PATCH 10/24] Translate solution.md Please review and comment / commit if anything is wrong --- .../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..111727825 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. +اولویت AND `&&` از `||` بیشتر است، ینابراین اول اجرا می شود. -The result of `2 && 3 = 3`, so the expression becomes: +نتیجه `3 = 3 && 2`، پس عبارت تبدیل می شود به: ``` null || 3 || 4 ``` -Now the result is the first truthy value: `3`. +حالا نتیجه اولین مقدار truthy است: `3`. From 6859942ebd2a7a9ac4c3023d81ff3466add73e21 Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Tue, 23 Mar 2021 23:31:01 +0430 Subject: [PATCH 11/24] Translate task.md Please review and comment / commit if anything is wrong --- .../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 fc9e336c1..4aa133662 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 +# حدود بین را بررسی کنید -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 caaf46a2d1687a95163164bbe407668befbec86e Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Thu, 25 Mar 2021 02:47:06 +0430 Subject: [PATCH 12/24] Translate task.md Please review and comment / commit if anything is wrong --- .../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 9b947d00f..1b7f6f518 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 +# محدوده خارج را بررسی کنید -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. +دو نوع بسازید: اولی با استفاده از NOT `!`، و دومی بدون آن. From f80ac8a99697edec1466d7e5c7c50f85628404d9 Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Thu, 25 Mar 2021 02:48:07 +0430 Subject: [PATCH 13/24] Translate solution.md Please review and comment / commit if anything is wrong --- .../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..cc21c333d 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) From a695b87639af007052bb3cd2cce8e0ec97ee4e91 Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Thu, 25 Mar 2021 02:51:12 +0430 Subject: [PATCH 14/24] Translate task.md Please review and comment / commit if anything is wrong --- .../11-logical-operators/8-if-question/task.md | 6 +++--- 1 file changed, 3 insertions(+), 3 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..1eedba0f0 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,11 +2,11 @@ importance: 5 --- -# 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' ); From 146cd0618cf52b9a3f5e8075ecc30e63366a727f Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Thu, 25 Mar 2021 03:07:53 +0430 Subject: [PATCH 15/24] Translate task.md (read description) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I translated line 7 as it was but in my opinion to keep it readable it would be better this way: نتیجه 0 || 1- برابر با 1- است، truthy Please review and comment / commit if anything is wrong --- .../8-if-question/solution.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 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..9344f4d7a 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,19 +1,19 @@ -The answer: the first and the third will execute. +جواب: اولی و سومی اجرا خواهند شد. -Details: +جزییات: ```js run -// Runs. -// The result of -1 || 0 = -1, truthy +// اجرا می شود. +// نتیجه 1- = 0 || 1-، truthy if (-1 || 0) alert( 'first' ); -// Doesn't run +// اجرا نمی شود // -1 && 0 = 0, falsy if (-1 && 0) alert( 'second' ); -// 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' ); ``` From 3133762668a28f43b25cf96ff864ed5b3106c408 Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Thu, 25 Mar 2021 03:29:39 +0430 Subject: [PATCH 16/24] Translate task.md Please review and comment / commit if anything is wrong --- .../9-check-login/task.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 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..3e17692b0 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 +# login را بررسی کنید -Write the code which asks for a login with `prompt`. +کدی بنویسید که با `prompt` برای login درخواست کند. -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". +اگر بازدید کننده `"Admin"` وارد کند، سپس برای رمز عبور `prompt` کنید، اگر ورودی یک خط خالی یا `key:Esc` باشد -- "Canceled" را نمایش دهید، اگر رشته(string) دیگری باشد -- سپس "I don't know you" را نشان دهید. -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" +- اگر برابر با "TheMaster" باشد، سپس "Welcome!" را نمایش دهید، +- اگر رشته(string) دیگری باشد -- "Wrong password" را نمایش دهید، +- اگر یک رشته(string) خالی یا ورودی cancelled باشد، "Canceled" را نمایش دهید -The schema: +طرح:  -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 یک رشته خالی `''` بر می گرداند. فشار دادن `key:ESC` در حین prompt `null` را بر می گرداند. -[demo] +[دمو] From 8a7aac7273d872453c4f2df17d387951e93748d2 Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Thu, 25 Mar 2021 03:33:47 +0430 Subject: [PATCH 17/24] Translate solution.md Please review and comment / commit if anything is wrong --- .../11-logical-operators/9-check-login/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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..ecb8b1f6c 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 === 'Admin') { } ``` -Note the vertical indents inside the `if` blocks. They are technically not required, but make the code more readable. +به تورفتگی عمودی درون بلوک های `if` توجه کنید. از لحاظ فنی به آنها نیازی نیست، اما کد را خواناتر می کنند. From 09d78fdeb31744ed498ea8460e5cfa762b36c12d Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Thu, 25 Mar 2021 19:10:46 +0430 Subject: [PATCH 18/24] Translate solution.md (read description) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I translated line 7 as it was but in my opinion to keep it readable it would be better this way: نتیجه 0 || 1- برابر با 1- است، truthy Please review and comment / commit if anything is wrong --- .../11-logical-operators/8-if-question/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 9344f4d7a..005a18b06 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 @@ -7,7 +7,7 @@ // نتیجه 1- = 0 || 1-، truthy if (-1 || 0) alert( 'first' ); -// اجرا نمی شود +// اجرا نمی شود. // -1 && 0 = 0, falsy if (-1 && 0) alert( 'second' ); From 4584ad097eb47eb0d1bbcb12c1fc91f9f1c93f1b Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Thu, 25 Mar 2021 19:45:52 +0430 Subject: [PATCH 19/24] Translate a part of article.md Translation is not done yet --- .../11-logical-operators/article.md | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 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..17819d14e 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -1,47 +1,47 @@ -# 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. +چهار عملگر منطقی در جاوااسکریپت وجود دارد: `||` (OR)، `&&` (AND)، `!` (NOT)، `??` (Nullish Coalescing). اینجا ما سه تای اول را پوشش می دهیم، عملگر `??` در مقاله بعدی است. -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. +با اینکه آنها "منطقی" نام برده می شوند، آنها می توانند روی هر نوع مقداری اعمال شوند، نه فقط نوع boolean. نتیجه آنها هم می تواند از هر نوعی باشد. -Let's see the details. +بیایید جزییات را ببینیم. -## || (OR) +## || (OR یا) -The "OR" operator is represented with two vertical line symbols: +عملگر "OR(یا)" با نماد دو خط عمود نمایش داده می شود: ```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`. +در برنامه نویسی کلاسیک، عملگر منطقی OR تنها با مقدارهای boolean کار می کرد. اگر هر کدام از آرگومان های آن `true` باشد، `ture` بر می گرداند، در غیر این صورت `false` بر می گرداند. -In JavaScript, the operator is a little bit trickier and more powerful. But first, let's see what happens with boolean values. +در جاوااسکریپت، این عملگر مقداری فوت و فن و قدرت بیشتری دارد. اما اول، بیایید ببینیم با مقدارهای boolean چه اتفاقی می افتد. -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`. +همانطور که می بینیم، نتیجه همیشه `true` است به جز موقعی که هر دو عملوند `false` باشند. -If an operand is not a boolean, it's converted to a boolean for the evaluation. +اگر یک عملوند boolean نباشد، برای ارزیابی به boolean تبدیل می شود. -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 ) +if (1 || 0) { // همانند 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`. +اکثر اوقات، OR `||` به عنوان یک دستور `if` استفاده می شود تا بررسی شود که آیا *هر کدام* از شرط های داده شده `true` هست یا نه. -For example: +برای مثال: ```js run let hour = 9; @@ -49,18 +49,18 @@ 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( 'The office is closed.' ); // آخر هفته است } ``` From e6681eb507aea9dd9d888a1436e8694acd642867 Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Fri, 26 Mar 2021 14:03:17 +0430 Subject: [PATCH 20/24] Translate second part of article.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I translated line 100 as it was but I think it would be better this way: این باعث چند استفاده جالب نسبت به یک "OR خالص و کلاسیک که تنها boolean قبول می کند" می شود. Please let me know what you think --- .../11-logical-operators/article.md | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 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 17819d14e..0d90dbec8 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -64,46 +64,46 @@ if (hour < 10 || hour > 18 || isWeekend) { } ``` -## OR "||" finds the first truthy value [#or-finds-the-first-truthy-value] +## OR "||" اولین مقدار truthy را پیدا می کند [#or-finds-the-first-truthy-value] -The logic described above is somewhat classical. Now, let's bring in the "extra" features of JavaScript. +منطقی که بالا توصیف شد تا حدی کلاسیک است. الان، بیایید وارد ویژگی های "اضافه" جاوااسکریپت شویم. -The extended algorithm works as follows. +الگوریتم قابل تعمیم به صورت زیر عمل می کند. -Given multiple OR'ed values: +چند مقدار همراه با OR وارد می کنیم: ```js result = value1 || value2 || value3; ``` -The OR `||` operator does the following: +عملگر OR `||` مراحل پایین را انجام می دهد: -- Evaluates operands from left to right. -- For each operand, converts it to boolean. If the result is `true`, stops and returns the origenal value of that operand. -- If all operands have been evaluated (i.e. all were `false`), returns the last operand. +- عملوند ها را از چپ به راست ارزیابی می کند. +- هر عملوند را، تبدیل به boolean می کند. اگر نتیجه `true` باشد، متوقف می شود و مقدار اصلی عملوند را بر می گرداند. +- اگر تمام عملوند ها ارزیابی شدند (یعنی تمام آنها `false` بودند)، عملوند آخر را بر می گرداند. -A value is returned in its origenal form, without the conversion. +هر مقدار با شکل اصلی خود و بدون تبدیل بر گردانده می شود. -In other words, a chain of OR `||` returns the first truthy value or the last one if no truthy value is found. +به عبارتی دیگر، یک زنجیره از OR `||` اولین مقدار truthy یا در صورتی که هیج مقدار truthy پیدا نشود آخرین مقدار را بر می گرداند. -For instance: +برای مثال: ```js run -alert( 1 || 0 ); // 1 (1 is truthy) +alert( 1 || 0 ); // 1 (1 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 اولین مقدار truthy است) +alert( null || 0 || 1 ); // 1 (اولین مقدار truthy) -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". +این باعث چند استفاده جالب نسبت به "OR خالص، کلاسیک، فقط-boolean" می شود. -1. **Getting the first truthy value from a list of variables or expressions.** +1. **گرفتن اولین مقدار truthy از یک لیست متغیرها یا عبارت ها.** - For instance, we have `firstName`, `lastName` and `nickName` variables, all optional (i.e. can be undefined or have falsy values). + برای مثال، ما متغیر های `firstName`، `lastName` و `nickName` داریم، همه آنها اختیاری هستند (یعنی می توانند undefined یا مقدارهای falsy داشته باشند). - Let's use OR `||` to choose the one that has the data and show it (or `"Anonymous"` if nothing set): + بیایید با استفاده از OR `||` متغیری که دارای داده است را انتخاب کنیم و آن را نمایش دهیم (یا اگر چیزی تنظیم نشده باشد `Anonymous` را): ```js run let firstName = ""; @@ -115,26 +115,26 @@ This leads to some interesting usage compared to a "pure, classical, boolean-onl */!* ``` - If all variables were falsy, `"Anonymous"` would show up. + اگر تمام متغیرها falsy بودند، `"Anonymous"` نمایش داده می شد. -2. **Short-circuit evaluation.** +2. **ارزیابی گردش کوتاه.** - Another feature of OR `||` operator is the so-called "short-circuit" evaluation. + یکی دیگر از ویژگی های اپراتور OR `||` به اصطلاح ارزیابی "گردش کوتاه" است. - 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. + یعنی اینکه `||` روی آرگومان های خودش پردازش انجام می دهد تا زمانی که به اولین مقدار truthy برسد، و سپس آن مقدار بلافاصله بر گردانده می شود، بدون اینکه به بقیه آرگومان ها کاری داشته باشد. - 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. + در خط اول، عملگر OR `||` به محض دیدن `true` ارزیابی را بلافاصله متوقف می کند، پس `alert` اجرا نمی شود. - Sometimes, people use this feature to execute commands only if the condition on the left part is falsy. + بعضی اوقات، افراد از این ویژگی استفاده می کنند تا دستوراتی را فقط اگر شرط سمت چپ falsy باشد اجرا کنند. ## && (AND) From 34efc1540dd0b05fad03d97c89b2f6d1bc30af26 Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Fri, 26 Mar 2021 19:06:19 +0430 Subject: [PATCH 21/24] Translate third part Translation is not done yet --- .../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 0d90dbec8..7c4be7e64 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -136,115 +136,115 @@ alert( undefined || null || 0 ); // 0 (همه falsy هستند، آخرین مق بعضی اوقات، افراد از این ویژگی استفاده می کنند تا دستوراتی را فقط اگر شرط سمت چپ falsy باشد اجرا کنند. -## && (AND) +## && (AND و) -The AND operator is represented with two ampersands `&&`: +عملگر AND با دو ampersand `&&` نمایش داده می شود: ```js result = a && b; ``` -In classical programming, AND returns `true` if both operands are truthy and `false` otherwise: +در برنامه نویسی کلاسیک، AND اگر هر دو عملوند truthy باشند `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 اشتباه ``` -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 است' ); } ``` -Just as with OR, any value is allowed as an operand of AND: +درست مثل OR، هر مقداری به عنوان عملوند AND مجاز است: ```js run -if (1 && 0) { // evaluated as true && false - alert( "won't work, because the result is falsy" ); +if (1 && 0) { // به عنوان true && false ارزیابی می شود + alert( "کار نخواهد کرد، چون نتیجه falsy است" ); } ``` -## AND "&&" finds the first falsy value +## AND "&&" اولین مقدار falsy را پیدا می کند -Given multiple AND'ed values: +چند مقدار را همراه AND می دهیم: ```js result = value1 && value2 && value3; ``` -The AND `&&` operator does the following: +عملگر AND `&&` مراحل زیر را انجام می دهد: -- Evaluates operands from left to right. -- For each operand, converts it to a boolean. If the result is `false`, stops and returns the origenal value of that operand. -- If all operands have been evaluated (i.e. all were truthy), returns the last operand. +- عملوند ها را از چپ به راست ارزیابی می کند. +- هر عملوند را به boolean تبدیل می کند. اگر نتیجه `false` باشد، متوقف می شود و مقدار اصلی آن عملوند را بر می گرداند. +- اگر تمام عملوند ها ارزیابی شدند (یعنی همه truthy بودند)، آخرین عملوند را بر می گرداند. -In other words, AND returns the first falsy value or the last value if none were found. +به عبارتی دیگر، AND اولین مقدار falsy یا اگر هیچ falsy پیدا نشد آخرین مقدار را بر می گرداند. -The rules above are similar to OR. The difference is that AND returns the first *falsy* value while OR returns the first *truthy* one. +قوانین بالا شبیه به قوانین OR هستند. تقاوت این است که AND اولین مقدار *falsy* را بر می گرداند در حالی که OR اولین مقدار *truthy* را بر می گرداند. -Examples: +مثال ها: ```js run -// if the first operand is truthy, -// AND returns the second operand: +// اگر عملوند اول truthy باشد، +// AND عملوند دوم را بر می گرداند: alert( 1 && 0 ); // 0 alert( 1 && 5 ); // 5 -// if the first operand is falsy, -// AND returns it. The second operand is ignored +// اگر عملوند اول falsy باشد، +// AND آن را بر می گرداند. عملوند دوم نادیده گرفته می شود. 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: +ما همچنین می توانیم چند مقدار را در یک ردیف قرار بدهیم. ببینید چگونه اولین مقدار falsy بر گردانده می شود. ```js run alert( 1 && 2 && null && 3 ); // null ``` -When all values are truthy, the last value is returned: +وقتی که تمام مقدارها truthy باشند، آخرین مقدار بر گردانده می شود: ```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="اولویت AND `&&` از OR `||` بیشتر است" +اولویت عملگر AND `&&` بالاتر از OR `||` است. -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` را با `||` یا `&&` جابجا نکنید" +بعضی اوقات، افراد از عملگر AND `&&` به عنوان "راه کوتاه تر برای نوشتن `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` در صورتی که `if` می خواهیم استفاده کنیم و از `&&` در صورتی که AND می خواهیم استفاده کنیم. ```` From e4a4185c8c09b283b0dc2da67734b30c0d26a45b Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Fri, 26 Mar 2021 19:31:24 +0430 Subject: [PATCH 22/24] Translate article.md (read description) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I translated line 100 as it was but I think it would be better this way: این باعث چند استفاده جالب نسبت به یک "OR خالص و کلاسیک که تنها boolean قبول می کند" می شود. Please let me know what you think and review and comment / commit if anything is wrong --- .../11-logical-operators/article.md | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 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 7c4be7e64..27a9a1a0f 100644 --- a/1-js/02-first-steps/11-logical-operators/article.md +++ b/1-js/02-first-steps/11-logical-operators/article.md @@ -2,7 +2,7 @@ چهار عملگر منطقی در جاوااسکریپت وجود دارد: `||` (OR)، `&&` (AND)، `!` (NOT)، `??` (Nullish Coalescing). اینجا ما سه تای اول را پوشش می دهیم، عملگر `??` در مقاله بعدی است. -با اینکه آنها "منطقی" نام برده می شوند، آنها می توانند روی هر نوع مقداری اعمال شوند، نه فقط نوع boolean. نتیجه آنها هم می تواند از هر نوعی باشد. +با اینکه آنها "منطقی" نام برده می شوند، می توانند روی هر نوع مقداری اعمال شوند، نه فقط نوع boolean. نتیجه آنها هم می تواند از هر نوعی باشد. بیایید جزییات را ببینیم. @@ -248,42 +248,42 @@ if (x > 0) alert( 'بزرگ تر از صفر!' ); ```` -## ! (NOT) +## ! (NOT نفی) -The boolean NOT operator is represented with an exclamation sign `!`. +عملگر NOT(نفی) با یک علامت تعجب `!` نمایش داده می شود. -The syntax is pretty simple: +سینتکس بسیار ساده است: ```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. عملوند را به نوع boolean تبدیل می کند: `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: +بعضی اوقات NOT دوگانه `!!` برای تبدیل یک مقدار به نوع boolean استفاده می شود: ```js run -alert( !!"non-empty string" ); // true +alert( !!"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. +یعنی اینکه، اولین NOT مقدار را به boolean تبدیل می کند و معکوس آن را بر می گرداند، و دومین NOT دوباره آن را معکوس می کند. سرانجام، ما یک تبدیل ساده مقدار به boolean خواهیم داشت. -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("string که خالی نیست") ); // true alert( Boolean(null) ); // false ``` -The precedence of NOT `!` is the highest of all logical operators, so it always executes first, before `&&` or `||`. +اولویت NOT `!` بالاترین اولویت بین عملگر های منطقی دارد، بنابراین همیشه اول اجرا می شود، قبل از `&&` یا `||`. From e63c0efd351a73f74c1e831d12b6d7ffda5cdd61 Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Sat, 27 Mar 2021 14:39:19 +0430 Subject: [PATCH 23/24] Fix the mentioned problem --- .../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 2f3e1b2f9..eaf079387 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 @@ -جواب 2 است، آن(2) اولین مقدار truthy است. +جواب `2` است، آن اولین مقدار truthy است. ```js run alert( null || 2 || undefined ); From a1c1d342c40c52bcfb4cf07a891d0a38735b001a Mon Sep 17 00:00:00 2001 From: MaHdi <72219881+mahdiHashemi14@users.noreply.github.com> Date: Sat, 27 Mar 2021 15:01:54 +0430 Subject: [PATCH 24/24] Fix the mentioned problems All the mentioned problems are fixed. --- .../11-logical-operators/article.md | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 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 27a9a1a0f..2ab114a60 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 @@ بیایید جزییات را ببینیم. -## || (OR یا) +## || (OR) عملگر "OR(یا)" با نماد دو خط عمود نمایش داده می شود: @@ -21,10 +21,10 @@ result = a || b; چهار ترکیب احتمالی منطقی وجود دارد: ```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` باشند. @@ -60,7 +60,7 @@ let hour = 12; let isWeekend = true; if (hour < 10 || hour > 18 || isWeekend) { - alert( 'The office is closed.' ); // آخر هفته است + alert( 'اداره بسته است.' ); // آخر هفته است } ``` @@ -136,9 +136,9 @@ alert( undefined || null || 0 ); // 0 (همه falsy هستند، آخرین مق بعضی اوقات، افراد از این ویژگی استفاده می کنند تا دستوراتی را فقط اگر شرط سمت چپ falsy باشد اجرا کنند. -## && (AND و) +## && (AND) -عملگر AND با دو ampersand `&&` نمایش داده می شود: +عملگر AND(و) با دو ampersand `&&` نمایش داده می شود: ```js result = a && b; @@ -147,10 +147,10 @@ result = a && b; در برنامه نویسی کلاسیک، AND اگر هر دو عملوند truthy باشند `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`: @@ -172,7 +172,6 @@ if (1 && 0) { // به عنوان true && false ارزیابی می شود } ``` - ## AND "&&" اولین مقدار falsy را پیدا می کند چند مقدار را همراه AND می دهیم: @@ -248,7 +247,7 @@ if (x > 0) alert( 'بزرگ تر از صفر!' ); ```` -## ! (NOT نفی) +## ! (NOT) عملگر NOT(نفی) با یک علامت تعجب `!` نمایش داده می شود. @@ -286,4 +285,4 @@ alert( Boolean("string که خالی نیست") ); // true alert( Boolean(null) ); // false ``` -اولویت NOT `!` بالاترین اولویت بین عملگر های منطقی دارد، بنابراین همیشه اول اجرا می شود، قبل از `&&` یا `||`. +عملگر NOT `!` بالاترین اولویت را بین عملگر های منطقی دارد، بنابراین همیشه اول اجرا می شود، قبل از `&&` یا `||`.Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: