From 1c4715255e88a3a112411bd41cc308e5f2f185cd Mon Sep 17 00:00:00 2001 From: MaHdi Date: Sun, 29 Aug 2021 15:03:17 +0430 Subject: [PATCH 01/15] Translate a part of article --- 1-js/02-first-steps/10-ifelse/article.md | 26 ++++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/1-js/02-first-steps/10-ifelse/article.md b/1-js/02-first-steps/10-ifelse/article.md index 806cebbd3..55e633bf8 100644 --- a/1-js/02-first-steps/10-ifelse/article.md +++ b/1-js/02-first-steps/10-ifelse/article.md @@ -1,35 +1,35 @@ -# Conditional branching: if, '?' +# انشعاب شرطی: if، '?' -Sometimes, we need to perform different actions based on different conditions. +بعضی اوقات، ما نیاز داریم که کارهای مختلفی را بر اساس شرایط مختلف انجام دهیم. -To do that, we use the `if` statement and the conditional (ternary) operator which we will be referring to as the “question mark” operator `?` for simplicity. +برای انجام این کار، ما از دستور `if` و عملگر شرطی (سه‌تایی) که ما برای سادگی به عنوان عملگر «علامت سوال» `?` به آن اشاره خواهیم کرد، استفاده می‌کنیم. -## The "if" statement +## دستور "if" -The `if(...)` statement evaluates a condition in parentheses and, if the result is `true`, executes a block of code. +دستور `if(...)` شرطی را در پرانتزها ارزیابی می‌کند و اگر نتیجه آن `true` باشد، یک بلوک کد را اجرا می‌کند. -For example: +برای مثال: ```js run -let year = prompt('In which year was ECMAScript-2015 specification published?', ''); +let year = prompt('در چه سالی مشخصات ECMAScript-2015 منتشر شد', ''); *!* -if (year == 2015) alert( 'You are right!' ); +if (year == 2015) alert( 'درست گفتید!' ); */!* ``` -In the example above, the condition is a simple equality check (`year == 2015`), but it can be much more complex. +در مثال بالا، شرط یک بررسی برابری ساده است (`year == 2015`) اما می‌تواند خیلی پیچیده‌تر باشد. -If we want to execute more than one statement, we have to wrap our code block inside curly braces: +اگر ما بخواهیم بیشتر از یک دستور را اجرا کنیم، باید کدمان را درون آکولاد قرار دهیم: ```js if (year == 2015) { - alert( "That's correct!" ); - alert( "You're so smart!" ); + alert( "درست است!" ); + alert( "شما باهوش هستید!" ); } ``` -We recommend wrapping your code block with curly braces `{}` every time you use an `if` statement, even if there is only one statement to execute. Doing so improves readability. +ما پیشنهاد می‌کنیم که کدتان را هر بار که از دستور `if` استفاده می‌کنید، درون آکولاد `{}` بگذارید حتی اگر تنها یک دستور برای اجرا کردن دارید. انجام دادن این کار خوانایی را افزایش می‌دهد. ## Boolean conversion From 402ee532031872a99cba31d56bb2c7954b27a527 Mon Sep 17 00:00:00 2001 From: MaHdi Date: Mon, 30 Aug 2021 14:23:11 +0430 Subject: [PATCH 02/15] Translate a part of article --- 1-js/02-first-steps/10-ifelse/article.md | 36 ++++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/1-js/02-first-steps/10-ifelse/article.md b/1-js/02-first-steps/10-ifelse/article.md index 55e633bf8..a4ec4e764 100644 --- a/1-js/02-first-steps/10-ifelse/article.md +++ b/1-js/02-first-steps/10-ifelse/article.md @@ -11,7 +11,7 @@ برای مثال: ```js run -let year = prompt('در چه سالی مشخصات ECMAScript-2015 منتشر شد', ''); +let year = prompt('در چه سالی مشخصات ECMAScript-2015 منتشر شد؟', ''); *!* if (year == 2015) alert( 'درست گفتید!' ); @@ -31,53 +31,53 @@ if (year == 2015) { ما پیشنهاد می‌کنیم که کدتان را هر بار که از دستور `if` استفاده می‌کنید، درون آکولاد `{}` بگذارید حتی اگر تنها یک دستور برای اجرا کردن دارید. انجام دادن این کار خوانایی را افزایش می‌دهد. -## Boolean conversion +## تبدیل به بولین -The `if (…)` statement evaluates the expression in its parentheses and converts the result to a boolean. +دستور `if (…)` عبارت درون پرانتزها را ارزیابی می‌کند و نتیجه را به بولین تبدیل می‌کند. -Let's recall the conversion rules from the chapter : +بیایید قوانین تبدیل را از فصل به یاد بیاریم: -- A number `0`, an empty string `""`, `null`, `undefined`, and `NaN` all become `false`. Because of that they are called "falsy" values. -- Other values become `true`, so they are called "truthy". +- عدد `0`، یک رشته خالی `""`، `null`، `undefined` و `NaN` همگی به `false` تبدیل می‌شوند. به همین دلیل به آنها مقدارهای "falsy" می‌گویند. +- مقدارهای دیگر به `true` تبدیل می‌شوند پس "truthy" نامیده می‌شوند. -So, the code under this condition would never execute: +پس کد زیر با این شرط هیچگاه اجرا نمی‌شود: ```js -if (0) { // 0 is falsy +if (0) { // است falsy ،مقدار 0 ... } ``` -...and inside this condition -- it always will: +...و درون با این شرط -- همیشه اجرا می‌شود: ```js -if (1) { // 1 is truthy +if (1) { // است truthy ،مقدار 1 ... } ``` -We can also pass a pre-evaluated boolean value to `if`, like this: +همچنین ما می‌توانیم یک مقدار بولین که از قبل ارزیابی شده است را به `if` بدهیم، مانند اینجا: ```js -let cond = (year == 2015); // equality evaluates to true or false +let cond = (year == 2015); // false است یا true برابری بعد از ارزیابی یا if (cond) { ... } ``` -## The "else" clause +## عبارت "else" -The `if` statement may contain an optional "else" block. It executes when the condition is falsy. +دستور `if` ممکن است یک بلوک اختیاری "else" هم شامل شود. این بلوک زمانی که شرط falsy باشد اجرا می‌شود. -For example: +برای مثال: ```js run -let year = prompt('In which year was the ECMAScript-2015 specification published?', ''); +let year = prompt('در چه سالی مشخصات ECMAScript-2015 منتشر شد؟', ''); if (year == 2015) { - alert( 'You guessed it right!' ); + alert( 'شما درست حدس زدید!' ); } else { - alert( 'How can you be so wrong?' ); // any value except 2015 + alert( 'چطور اشتباه گفتید؟' ); // هر مقداری به جز 2015 } ``` From dac31efeb71ab04162076a821f8871cd51ab3da4 Mon Sep 17 00:00:00 2001 From: MaHdi Date: Tue, 31 Aug 2021 15:23:36 +0430 Subject: [PATCH 03/15] Translate a part of article --- 1-js/02-first-steps/10-ifelse/article.md | 52 ++++++++++++------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/1-js/02-first-steps/10-ifelse/article.md b/1-js/02-first-steps/10-ifelse/article.md index a4ec4e764..5532e0ea0 100644 --- a/1-js/02-first-steps/10-ifelse/article.md +++ b/1-js/02-first-steps/10-ifelse/article.md @@ -81,37 +81,37 @@ if (year == 2015) { } ``` -## Several conditions: "else if" +## چند شرط: "else if" -Sometimes, we'd like to test several variants of a condition. The `else if` clause lets us do that. +گاهی اوقات، ما می‌خواهیم که چند نوع از یک شرط را آزمایش کنیم. عبارت `else if` به امکان همچین کاری را می‌دهد. -For example: +برای مثال: ```js run -let year = prompt('In which year was the ECMAScript-2015 specification published?', ''); +let year = prompt('در چه سالی مشخصات ECMAScript-2015 منتشر شد؟', ''); if (year < 2015) { - alert( 'Too early...' ); + alert( 'کم گفتید...' ); } else if (year > 2015) { - alert( 'Too late' ); + alert( 'زیاد گفتید' ); } else { - alert( 'Exactly!' ); + alert( 'دقیقا!' ); } ``` -In the code above, JavaScript first checks `year < 2015`. If that is falsy, it goes to the next condition `year > 2015`. If that is also falsy, it shows the last `alert`. +در کد بالا، جاوااسکریپت در ابتدا `year < 2015` را بررسی می‌کند. اگر falsy باشد، به شرط بعدی `year > 2015` می‌رود. اگر آن هم falsy باشد، `alert` آخر نمایش داده می‌شود. -There can be more `else if` blocks. The final `else` is optional. +بلوک‌های `else if` بیشتری هم می‌تواند وجود داشته باشد. `else` آخری اختیاری است. -## Ternary operator '?' +## عملگر سه‌گانه '?' -Sometimes, we need to assign a variable depending on a condition. +گاهی اوقات، ما نیاز داریم که بر اساس شرطی، یک متغیر را مقداردهی کنیم. -For instance: +برای مثال: ```js run no-beautify let accessAllowed; -let age = prompt('How old are you?', ''); +let age = prompt('چند سال دارید؟', ''); *!* if (age > 18) { @@ -124,40 +124,40 @@ if (age > 18) { alert(accessAllowed); ``` -The so-called "ternary" or "question mark" operator lets us do that in a shorter and simpler way. +عملگر «سه‌گانه» یا «علامت سوال» به ما اجازه انجام این کار با روشی کوتاه‌تر و ساده‌تر را می‌دهد. -The operator is represented by a question mark `?`. The formal term "ternary" means that the operator has three operands. It is actually the one and only operator in JavaScript which has that many. +این عملگر با یک علامت سوال `?` نمایش داده می‌شود. عبارت رسمی «سه‌گانه» به معنی انی است که عملگر سه عملوند دارد. در واقع این عملگر، تنها عملگری در جاوااسکریپت است که این تعداد عملوند دارد. -The syntax is: +سینتکس آن: ```js let result = condition ? value1 : value2; ``` -The `condition` is evaluated: if it's truthy then `value1` is returned, otherwise -- `value2`. +بعد از اینکه `condition` ارزیابی شود: اگر truthy باشد سپس `value1` برگردانده می‌شود، در غیر این صورت -- `value2`. -For example: +برای مثال: ```js let accessAllowed = (age > 18) ? true : false; ``` + +به طور فنی، ما می‌توانیم پرانتزهای دور `age > 18` را حذف کنیم. عملگر علامت سوال اولویت پایینی دارد پس بعد از مقایسه `>` اجرا می‌شود. -Technically, we can omit the parentheses around `age > 18`. The question mark operator has a low precedence, so it executes after the comparison `>`. - -This example will do the same thing as the previous one: +این مثال کار یکسانی با مثال قبل انجام می‌دهد: ```js -// the comparison operator "age > 18" executes first anyway -// (no need to wrap it into parentheses) +// در هر صورت اول اجرا می‌شود "age > 18" عملگر مقایسه +// (نیازی نیست که آن را درون پرانتز بگذاریم) let accessAllowed = age > 18 ? true : false; ``` -But parentheses make the code more readable, so we recommend using them. +اما پرانتزها کد را خواناتر می‌کنند، پس ما پیشنهاد می‌کنیم که از آنها استفاده کنید. ````smart -In the example above, you can avoid using the question mark operator because the comparison itself returns `true/false`: +در مثال بالا، شما می‌توانید از عملگر علامت سوال استفاده نکنید چون خود مقایسه `true/false` برمی‌گرداند. ```js -// the same +// نتیجه یکسان است let accessAllowed = age > 18; ``` ```` From f04174b184a10b51c909dd0e5fe80e28af07574f Mon Sep 17 00:00:00 2001 From: MaHdi Date: Wed, 1 Sep 2021 13:49:08 +0430 Subject: [PATCH 04/15] Translate atricle --- 1-js/02-first-steps/10-ifelse/article.md | 64 ++++++++++++------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/1-js/02-first-steps/10-ifelse/article.md b/1-js/02-first-steps/10-ifelse/article.md index 5532e0ea0..a4bc551ad 100644 --- a/1-js/02-first-steps/10-ifelse/article.md +++ b/1-js/02-first-steps/10-ifelse/article.md @@ -162,78 +162,78 @@ let accessAllowed = age > 18; ``` ```` -## Multiple '?' +## بیشتر از یک علامت سوال '?' -A sequence of question mark operators `?` can return a value that depends on more than one condition. +یک دنباله از عملگرهای علامت سوال `?` می‌تواند مقداری که به بیشتر از یک شرط بستگی دارد را برگرداند. -For instance: +برای مثال: ```js run -let age = prompt('age?', 18); +let age = prompt('سن شما؟', 18); -let message = (age < 3) ? 'Hi, baby!' : - (age < 18) ? 'Hello!' : - (age < 100) ? 'Greetings!' : - 'What an unusual age!'; +let message = (age < 3) ? 'سلام کوچولو!' : + (age < 18) ? 'سلام!' : + (age < 100) ? 'درود!' : + 'چه سن غیر معمولی!'; alert( message ); ``` -It may be difficult at first to grasp what's going on. But after a closer look, we can see that it's just an ordinary sequence of tests: +ممکن است در نگاه اول فهمیدن اینکه چه چیزی در حال رخ دادن است سخت باشد. اما بعد از یک نگاه دقیق‌تر، متوجه می‌شویم که فقط یک دنباله معمولی از آزمایش‌ها است: -1. The first question mark checks whether `age < 3`. -2. If true -- it returns `'Hi, baby!'`. Otherwise, it continues to the expression after the colon '":"', checking `age < 18`. -3. If that's true -- it returns `'Hello!'`. Otherwise, it continues to the expression after the next colon '":"', checking `age < 100`. -4. If that's true -- it returns `'Greetings!'`. Otherwise, it continues to the expression after the last colon '":"', returning `'What an unusual age!'`. +1. اولین علامت سوال بررسی می‌کند که آیا `age < 3`. +2. اگر درست باشد -- `'سلام کوچولو!'` برگردانده می‌شود. در غیر این صورت به عبارت بعد از دو نقطه '":"' می‌رود و `age < 18` را بررسی می‌کند +3. اگر درست باشد -- `'سلام!'` را برمی‌گرداند. در غیر این صورت، به عبارت بعد از دو نقطه بعدی '":"' می‌رود و `age < 100` را بررسی می‌کند. +4. اگر درست باشد -- `'درود!'` را برمی‌گرداند. در غیر این صورت، به عبارت بعد از آخرین '":"' می‌رود و `'چه سن غیر معمولی!'` را برمی‌گرداند. -Here's how this looks using `if..else`: +اگر از `if..else` استفاده می‌شد، اینگونه بنظر می‌رسید: ```js if (age < 3) { - message = 'Hi, baby!'; + message = 'سلام کوچولو!'; } else if (age < 18) { - message = 'Hello!'; + message = 'سلام!'; } else if (age < 100) { - message = 'Greetings!'; + message = 'درود!'; } else { - message = 'What an unusual age!'; + message = 'چه سن غیر معمولی!'; } ``` -## Non-traditional use of '?' +## استفاده غیر سنتی از '?' -Sometimes the question mark `?` is used as a replacement for `if`: +بعضی اوقات علامت سوال `?` به عنوان جایگزینی برای `if` استفاده می‌شود: ```js run no-beautify -let company = prompt('Which company created JavaScript?', ''); +let company = prompt('کدام کمپانی جاوااسکریپت را ساخت؟', ''); *!* (company == 'Netscape') ? - alert('Right!') : alert('Wrong.'); + alert('درست گفتید!') : alert('اشتباه گفتید.'); */!* ``` -Depending on the condition `company == 'Netscape'`, either the first or the second expression after the `?` gets executed and shows an alert. +با توجه به شرط `company == 'Netscape'`، عبارت اول یا دوم بعد از `?` اجرا می‌شود و یک alert را نمایش می‌دهد. -We don't assign a result to a variable here. Instead, we execute different code depending on the condition. +اینجا ما یک نتیجه را برابر با یک متغیر قرار نمی‌دهیم. به جای آن، ما کد مختلف را بسته به شرایط اجرا می‌کنیم. -**It's not recommended to use the question mark operator in this way.** +**استفاده از عملگر علامت سوال به این روش اصلا پیشنهاد نمی‌شود.** -The notation is shorter than the equivalent `if` statement, which appeals to some programmers. But it is less readable. +این روش نسبت به دستور یکسان `if` کوتاه‌تر است، که بعضی از برنامه‌نویسان را جذب می‌کند. اما خوانایی کمتری دارد. -Here is the same code using `if` for comparison: +اینجا همان کد را با استفاده از `if` برای مقایسه آورده‌ایم: ```js run no-beautify -let company = prompt('Which company created JavaScript?', ''); +let company = prompt('کدام کمپانی جاوااسکریپت را ساخت؟', ''); *!* if (company == 'Netscape') { - alert('Right!'); + alert('درست گفتید!'); } else { - alert('Wrong.'); + alert('اشتباه گفتید.'); } */!* ``` -Our eyes scan the code vertically. Code blocks which span several lines are easier to understand than a long, horizontal instruction set. +چشمان ما کد را به صورت عمودی اسکن می‌کنند. بلوک‌های کد که در چند خط نوشته شده‌اند نسبت به یک مجموعه دستور طولانی و افقی، برای فهمیدن راحت‌تر هستند. -The purpose of the question mark operator `?` is to return one value or another depending on its condition. Please use it for exactly that. Use `if` when you need to execute different branches of code. +هدف عملگر علامت سوال `?` این است که یک مقدار یا مقدار دیگری را با توجه به شرایط آن برگرداند. لطفا دقیقا با همین هدف از آن استفاده کنید. زمانی که نیاز دارید شاخه‌های متفاوتی از کد را اجرا کنید از `if` استفاده کنید. From 5be97540fa7d21482ff5682ce5e276fa9caec0b9 Mon Sep 17 00:00:00 2001 From: MaHdi Date: Wed, 1 Sep 2021 13:54:03 +0430 Subject: [PATCH 05/15] typo --- 1-js/02-first-steps/10-ifelse/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/10-ifelse/article.md b/1-js/02-first-steps/10-ifelse/article.md index a4bc551ad..3937f7e6b 100644 --- a/1-js/02-first-steps/10-ifelse/article.md +++ b/1-js/02-first-steps/10-ifelse/article.md @@ -126,7 +126,7 @@ alert(accessAllowed); عملگر «سه‌گانه» یا «علامت سوال» به ما اجازه انجام این کار با روشی کوتاه‌تر و ساده‌تر را می‌دهد. -این عملگر با یک علامت سوال `?` نمایش داده می‌شود. عبارت رسمی «سه‌گانه» به معنی انی است که عملگر سه عملوند دارد. در واقع این عملگر، تنها عملگری در جاوااسکریپت است که این تعداد عملوند دارد. +این عملگر با یک علامت سوال `?` نمایش داده می‌شود. عبارت رسمی «سه‌گانه» به معنی این است که عملگر سه عملوند دارد. در واقع این عملگر، تنها عملگری در جاوااسکریپت است که این تعداد عملوند دارد. سینتکس آن: ```js From 5f03d00e3aab9974cbb9d40a7951a997fa4e8151 Mon Sep 17 00:00:00 2001 From: MaHdi Date: Wed, 1 Sep 2021 22:49:48 +0430 Subject: [PATCH 06/15] Upgrade readability and translate a sentence --- .../02-first-steps/10-ifelse/1-if-zero-string/solution.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/1-js/02-first-steps/10-ifelse/1-if-zero-string/solution.md b/1-js/02-first-steps/10-ifelse/1-if-zero-string/solution.md index 6460b8df6..e1ce7bc80 100644 --- a/1-js/02-first-steps/10-ifelse/1-if-zero-string/solution.md +++ b/1-js/02-first-steps/10-ifelse/1-if-zero-string/solution.md @@ -1,12 +1,12 @@ -**بله اجرا می شود.** +**بله اجرا می‌شود.** -هر رشته به جز رشته خالی (`"0"` خالی نیست!) از نظر منطقی true ارزیابی می شود. +هر رشته به جز رشته خالی (`"0"` خالی نیست!) از نظر منطقی true ارزیابی می‌شود. -می توانیم این تکه کد را اجرا کنیم و مورد بالا را بررسی کنیم: +می‌توانیم این تکه کد را اجرا کنیم و مورد بالا را بررسی کنیم: ```js run if ("0") { - alert( 'Hello' ); + alert( 'سلام' ); } ``` From e7689be981d292b21ced14d6c0da7cc7f27d2e10 Mon Sep 17 00:00:00 2001 From: MaHdi Date: Wed, 1 Sep 2021 22:54:02 +0430 Subject: [PATCH 07/15] Change two lines and translate a sentence Lines 5 and 7 are changed for better readability Argument of "alert" is translated --- 1-js/02-first-steps/10-ifelse/1-if-zero-string/task.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1-js/02-first-steps/10-ifelse/1-if-zero-string/task.md b/1-js/02-first-steps/10-ifelse/1-if-zero-string/task.md index 2b2328d69..367f15ed0 100644 --- a/1-js/02-first-steps/10-ifelse/1-if-zero-string/task.md +++ b/1-js/02-first-steps/10-ifelse/1-if-zero-string/task.md @@ -2,13 +2,13 @@ importance: 5 --- -# if (بررسی رشته با مقدار صفر) +# if (رشته‌ای شامل عدد صفر) -آیا `alert` اجرا می شود؟ +آیا `alert` اجرا می‌شود؟ ```js if ("0") { - alert( 'Hello' ); + alert( 'سلام' ); } ``` From d320fceb839ae52479058e7be9bec013b14cd2f1 Mon Sep 17 00:00:00 2001 From: MaHdi Date: Wed, 1 Sep 2021 22:59:07 +0430 Subject: [PATCH 08/15] Translate task of "check standard" --- 1-js/02-first-steps/10-ifelse/2-check-standard/task.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/1-js/02-first-steps/10-ifelse/2-check-standard/task.md b/1-js/02-first-steps/10-ifelse/2-check-standard/task.md index 4305584fa..1fcb61e35 100644 --- a/1-js/02-first-steps/10-ifelse/2-check-standard/task.md +++ b/1-js/02-first-steps/10-ifelse/2-check-standard/task.md @@ -2,12 +2,12 @@ importance: 2 --- -# The name of JavaScript +# اسم جاوااسکریپت -Using the `if..else` construct, write the code which asks: 'What is the "official" name of JavaScript?' +با استفاده از ساختار `if..else`، کدی بنویسید که بپرسد: 'What is the "official" name of JavaScript?' -If the visitor enters "ECMAScript", then output "Right!", otherwise -- output: "You don't know? ECMAScript!" +اگر بازدیدکننده "ECMAScript" را وارد کند، سپس پیام "Right!" را نشان دهید، در غیر این صورت این پیام را نشان دهید: "You don't know? ECMAScript!" ![](ifelse_task2.svg) -[demo src="ifelse_task2"] +[دمو src="ifelse_task2"] From 51cef87671faa2f56c9f6eff19b3132c1d8f8614 Mon Sep 17 00:00:00 2001 From: MaHdi Date: Wed, 1 Sep 2021 23:04:53 +0430 Subject: [PATCH 09/15] Translate task of "sign" --- 1-js/02-first-steps/10-ifelse/3-sign/task.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/1-js/02-first-steps/10-ifelse/3-sign/task.md b/1-js/02-first-steps/10-ifelse/3-sign/task.md index 0c5d0e008..a35d5aba4 100644 --- a/1-js/02-first-steps/10-ifelse/3-sign/task.md +++ b/1-js/02-first-steps/10-ifelse/3-sign/task.md @@ -2,14 +2,14 @@ importance: 2 --- -# Show the sign +# علامت را نشان دهید -Using `if..else`, write the code which gets a number via `prompt` and then shows in `alert`: +با استفاده از `if..else`، کدی بنویسید که با استفاده از `prompt` یک عدد می‌گیرد و سپس با `alert` یکی از اینها را نشان می‌دهد: -- `1`, if the value is greater than zero, -- `-1`, if less than zero, -- `0`, if equals zero. +- `1`، اگر مقدار بزرگ‌تر از صفر بود، +- `-1`، اگر کمتر از صفر بود، +- `0`، اگر برابر با صفر بود. -In this task we assume that the input is always a number. +در این تکلیف ما فرض می‌کنیم که ورودی همیشه یک عدد است. -[demo src="if_sign"] +[دمو src="if_sign"] From 14e665d2e9872404dab3562e9c39b0b216c0f29f Mon Sep 17 00:00:00 2001 From: MaHdi Date: Wed, 1 Sep 2021 23:05:37 +0430 Subject: [PATCH 10/15] Translate solution of "sign" --- 1-js/02-first-steps/10-ifelse/3-sign/solution.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/10-ifelse/3-sign/solution.md b/1-js/02-first-steps/10-ifelse/3-sign/solution.md index 262a605c2..70707239f 100644 --- a/1-js/02-first-steps/10-ifelse/3-sign/solution.md +++ b/1-js/02-first-steps/10-ifelse/3-sign/solution.md @@ -1,7 +1,7 @@ ```js run -let value = prompt('Type a number', 0); +let value = prompt('یک عدد وارد کنید', 0); if (value > 0) { alert( 1 ); From 0bfc6387154523ca884ee16fff844357fd4fe582 Mon Sep 17 00:00:00 2001 From: MaHdi Date: Wed, 1 Sep 2021 23:07:41 +0430 Subject: [PATCH 11/15] Translate task of "rewrite-if-question" --- .../10-ifelse/5-rewrite-if-question/task.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md b/1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md index 6bdf8453e..27399f4a9 100644 --- a/1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md +++ b/1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md @@ -2,16 +2,16 @@ importance: 5 --- -# Rewrite 'if' into '?' +# دستور 'if' را به '?' بازنویسی کنید -Rewrite this `if` using the conditional operator `'?'`: +این `if` را با استفاده از عملگر شرطی بازنویسی کنید: ```js let result; if (a + b < 4) { - result = 'Below'; + result = 'پایین'; } else { - result = 'Over'; + result = 'بالا'; } ``` From 1fb6d6f4d4a20a795640af3bc18c8c12c61f3cfd Mon Sep 17 00:00:00 2001 From: MaHdi Date: Wed, 1 Sep 2021 23:13:49 +0430 Subject: [PATCH 12/15] Revert translation of strings In the solution of this task if I translate the strings, the result wouldn't look like the way it should. That's why I reverted the translation. --- 1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md b/1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md index 27399f4a9..3336fe860 100644 --- a/1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md +++ b/1-js/02-first-steps/10-ifelse/5-rewrite-if-question/task.md @@ -10,8 +10,8 @@ importance: 5 let result; if (a + b < 4) { - result = 'پایین'; + result = 'Below'; } else { - result = 'بالا'; + result = 'Over'; } ``` From b64edb025a807279b6e8d6bb6ab8e2fac9f14d28 Mon Sep 17 00:00:00 2001 From: MaHdi Date: Wed, 1 Sep 2021 23:18:05 +0430 Subject: [PATCH 13/15] Translate solution of "rewrite-if-else-question" --- .../10-ifelse/6-rewrite-if-else-question/solution.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1-js/02-first-steps/10-ifelse/6-rewrite-if-else-question/solution.md b/1-js/02-first-steps/10-ifelse/6-rewrite-if-else-question/solution.md index 6d68e29d7..946dcdabd 100644 --- a/1-js/02-first-steps/10-ifelse/6-rewrite-if-else-question/solution.md +++ b/1-js/02-first-steps/10-ifelse/6-rewrite-if-else-question/solution.md @@ -1,9 +1,9 @@ ```js -let message = (login == 'Employee') ? 'Hello' : - (login == 'Director') ? 'Greetings' : - (login == '') ? 'No login' : +let message = (login == 'کارمند') ? 'سلام' : + (login == 'مدیر') ? 'درود' : + (login == '') ? 'به سیستم وارد نشدید' : ''; ``` From c4f3a20d9b7f5de29c846369718afaa3739e0d37 Mon Sep 17 00:00:00 2001 From: MaHdi Date: Wed, 1 Sep 2021 23:18:58 +0430 Subject: [PATCH 14/15] Translate task of "rewrite-if-else-question" --- .../10-ifelse/6-rewrite-if-else-question/task.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/1-js/02-first-steps/10-ifelse/6-rewrite-if-else-question/task.md b/1-js/02-first-steps/10-ifelse/6-rewrite-if-else-question/task.md index 4f7d994a2..eaee6c4b2 100644 --- a/1-js/02-first-steps/10-ifelse/6-rewrite-if-else-question/task.md +++ b/1-js/02-first-steps/10-ifelse/6-rewrite-if-else-question/task.md @@ -2,21 +2,21 @@ importance: 5 --- -# Rewrite 'if..else' into '?' +# دستور 'if..else' را به '?' بازنویسی کنید -Rewrite `if..else` using multiple ternary operators `'?'`. +با استفاده از چند عملگر سه‌گانه `'?'` دستور `if..else` را بازنویسی کنید. -For readability, it's recommended to split the code into multiple lines. +برای خوانایی، پیشنهاد می‌شود که کد را در چند خط بنویسید. ```js let message; -if (login == 'Employee') { - message = 'Hello'; -} else if (login == 'Director') { - message = 'Greetings'; +if (login == 'کارمند') { + message = 'سلام'; +} else if (login == 'مدیر') { + message = 'درود'; } else if (login == '') { - message = 'No login'; + message = 'وارد سیستم نشدید'; } else { message = ''; } From 864f7f99c09ec9b0a01febddeee8be9c57f16448 Mon Sep 17 00:00:00 2001 From: MaHdi Date: Wed, 1 Sep 2021 23:21:03 +0430 Subject: [PATCH 15/15] Remove a word and add one for better readability --- .../02-first-steps/10-ifelse/6-rewrite-if-else-question/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/10-ifelse/6-rewrite-if-else-question/task.md b/1-js/02-first-steps/10-ifelse/6-rewrite-if-else-question/task.md index eaee6c4b2..e26bf3ae8 100644 --- a/1-js/02-first-steps/10-ifelse/6-rewrite-if-else-question/task.md +++ b/1-js/02-first-steps/10-ifelse/6-rewrite-if-else-question/task.md @@ -6,7 +6,7 @@ importance: 5 با استفاده از چند عملگر سه‌گانه `'?'` دستور `if..else` را بازنویسی کنید. -برای خوانایی، پیشنهاد می‌شود که کد را در چند خط بنویسید. +برای خوانایی بهتر، پیشنهاد می‌شود کد را در چند خط بنویسید. ```js let message;