Skip to content

Commit 8291002

Browse files
committed
translated task & solution 2
1 parent c7875f9 commit 8291002

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
Using a question mark operator `'?'`:
1+
با استفاده از یک عملگر علامت سوال `'?'`:
22

33
```js
44
function checkAge(age) {
55
return (age > 18) ? true : confirm('Did parents allow you?');
66
}
77
```
88

9-
Using OR `||` (the shortest variant):
9+
با استفاده از OR `||` (کوتاه‌ترین حالت)
1010

1111
```js
1212
function checkAge(age) {
1313
return (age > 18) || confirm('Did parents allow you?');
1414
}
1515
```
1616

17-
Note that the parentheses around `age > 18` are not required here. They exist for better readabilty.
17+
توجه داشته باشید که پرانتزهای دور `age > 18` لازم نیست. برای خوانایی نوشته شده‌ند.

1-js/02-first-steps/14-function-basics/2-rewrite-function-question-or/task.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ importance: 4
22

33
---
44

5-
# Rewrite the function using '?' or '||'
5+
# تابع را با کمک '?' یا '||' بازنویسی کنید
66

7-
The following function returns `true` if the parameter `age` is greater than `18`.
7+
تابع زیر `true` را برمیگرداند اگر پارامتر `age` از `18` بزرگتر باشد.
8+
فلان را برمیگرداند
89

9-
Otherwise it asks for a confirmation and returns its result.
10+
در غیر اینصورت برای تأیید سوال می‌پرسد و سپس جواب را بر‌میگرداند:
1011

1112
```js
1213
function checkAge(age) {
13-
if (age > 18) {
14-
return true;
15-
} else {
16-
return confirm('Do you have your parents permission to access this page?');
17-
}
14+
if (age > 18) {
15+
return true;
16+
} else {
17+
return confirm('Do you have your parents permission to access this page?');
18+
}
1819
}
1920
```
2021

21-
Rewrite it, to perform the same, but without `if`, in a single line.
22-
23-
Make two variants of `checkAge`:
22+
بازنویسی کنید، تا همین رفتار، بدون `if`، در یک خط اجرا شود.
2423

25-
1. Using a question mark operator `?`
26-
2. Using OR `||`
24+
دو حالت از `checkAge` بسازید:
25+
۱. با استفاده از عملگر علامت سوال `?`
26+
۲. با استفاده از OR `||`

0 commit comments

Comments
 (0)