Skip to content

Commit 3a59e11

Browse files
authored
Merge pull request #14 from mostafaHegab/master
translate part 1, 2.11- logical operators to AR
2 parents 350f012 + f3df8c6 commit 3a59e11

18 files changed

Lines changed: 148 additions & 147 deletions

File tree

1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The answer is `2`, that's the first truthy value.
1+
الإجابة هي `2` لأنها أول قيمة truthy.
22

33
```js run
44
alert( null || 2 || undefined );

1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
importance: 5
1+
الأهمية: 5
22

33
---
44

5-
# What's the result of OR?
5+
# ما نتيجة OR?
66

7-
What is the code below going to output?
7+
ما خرج الأمر التالي ؟
88

99
```js
1010
alert( null || 2 || undefined );
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
The answer: first `1`, then `2`.
1+
الإجابة: أولًا `1` ثم `2`.
22

33
```js run
44
alert( alert(1) || 2 || alert(3) );
55
```
66

7-
The call to `alert` does not return a value. Or, in other words, it returns `undefined`.
7+
استدعائ `alert` لا يرجع أي قيمة أو بمعنى آخر يرجع `undefined`.
88

9-
1. The first OR `||` evaluates its left operand `alert(1)`. That shows the first message with `1`.
10-
2. The `alert` returns `undefined`, so OR goes on to the second operand searching for a truthy value.
11-
3. The second operand `2` is truthy, so the execution is halted, `2` is returned and then shown by the outer alert.
9+
1. أول OR `||` تنفذ العملية على يسارها `alert(1)`. وهذا يعرض أول رسالة `1`.
10+
2. إن `alert` ترجع `undefined` لذلك تنتقل OR للعملية الثانية بحثًا عن قيمة truthy.
11+
3. القيمة الثانية `2` هي truthy لذلك يتوقف التنفيذ وترجع `2` ويتم عرضها.
1212

13-
There will be no `3`, because the evaluation does not reach `alert(3)`.
13+
لن يتم عرض `3` لأن التنفيذ لم يصل إلى `alert(3)`.

1-js/02-first-steps/11-logical-operators/2-alert-or/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
importance: 3
1+
الأهمية: 3
22

33
---
44

5-
# What's the result of OR'ed alerts?
5+
# نتيجة التنبيهات التي بينها OR?
66

7-
What will the code below output?
7+
ما خرج الكود التالي ؟
88

99
```js
1010
alert( alert(1) || 2 || alert(3) );

1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The answer: `null`, because it's the first falsy value from the list.
1+
الإجابة: `null` لأنها أول قيمة falsy في القائمة.
22

33
```js run
44
alert( 1 && null && 2 );

1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
importance: 5
1+
الأهمية: 5
22

33
---
44

5-
# What is the result of AND?
5+
# نتيحة AND?
66

7-
What is this code going to show?
7+
ما خرج الكود التالي ؟
88

99
```js
1010
alert( 1 && null && 2 );
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
The answer: `1`, and then `undefined`.
1+
الإجابة: `1` ثم `undefined`.
22

33
```js run
44
alert( alert(1) && alert(2) );
55
```
66

7-
The call to `alert` returns `undefined` (it just shows a message, so there's no meaningful return).
7+
استدعاء `alert` يرجع `undefined` (إنها تعرض رسالة لذلك لا يوجد معنى لإرجاع قيمة).
88

9-
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.
9+
وبسبب هذا تقوم `&&` بتنفيذ العملية على اليسار (تعرض `1`) وتتوقف لأن `undefined` تعتبر قيمة falsy. And `&&` تبحث عن قيمة falsy وترجعها.
1010

1-js/02-first-steps/11-logical-operators/4-alert-and/task.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ importance: 3
22

33
---
44

5-
# What is the result of AND'ed alerts?
5+
# نتيجة التنبيهات التي بينها AND?
6+
7+
ما خرج الكود التالي ؟
68

7-
What will this code show?
89

910
```js
1011
alert( alert(1) && alert(2) );
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
The answer: `3`.
1+
الإجابة: `3`.
22

33
```js run
44
alert( null || 2 && 3 || 4 );
55
```
66

7-
The precedence of AND `&&` is higher than `||`, so it executes first.
7+
أولوية AND `&&` أعلى من `||` لذلك تنفذ أولًا.
88

9-
The result of `2 && 3 = 3`, so the expression becomes:
9+
نتيجة `2 && 3 = 3` لذلك يصبح التعبير كالتالي:
1010

1111
```
1212
null || 3 || 4
1313
```
1414

15-
Now the result is the first truthy value: `3`.
15+
النتيجة الآن هي أول قيمة truthy: `3`.
1616

1-js/02-first-steps/11-logical-operators/5-alert-and-or/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
importance: 5
1+
الأهمية: 5
22

33
---
44

5-
# The result of OR AND OR
5+
# نتيجة OR AND OR
66

7-
What will the result be?
7+
ما ناتج تنفيذ الأمر التالي ؟
88

99
```js
1010
alert( null || 2 && 3 || 4 );

0 commit comments

Comments
 (0)