Skip to content

Commit 16823bb

Browse files
committed
merging all conflicts
2 parents dd3838b + b52aa94 commit 16823bb

11 files changed

Lines changed: 68 additions & 26 deletions

File tree

1-js/02-first-steps/08-operators/3-primitive-conversions-questions/solution.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ true + false = 1
1010
"4" - 2 = 2
1111
"4px" - 2 = NaN
1212
7 / 0 = Infinity
13-
" -9 " + 5 = " -9 5" // (3)
14-
" -9 " - 5 = -14 // (4)
13+
" -9 " + 5 = " -9 5" // (3)
14+
" -9 " - 5 = -14 // (4)
1515
null + 1 = 1 // (5)
1616
undefined + 1 = NaN // (6)
1717
" \t \n" - 2 = -2 // (7)

1-js/02-first-steps/12-nullish-coalescing-operator/article.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,19 @@ alert(height || 100); // 100
6363
alert(height ?? 100); // 0
6464
```
6565
66+
<<<<<<< HEAD
6667
هنا `height || 100` تعامل الصفر كـ `null`, `undefined` أو أي قيمة زائفة. اذا الصفر يصبح `100`.
6768
6869
ولكن `height ?? 100` ترجع `100` إذا كان فقط `height` يساوي تمامًا `null` أو `undefined`. اذا الصفر يبقى "كما هو".
6970
7071
يعتمد السلوك الافضل على حالة الاستخدام. تكون `??` الطريقة الافضل عندما يكون صفر height قيمة صالحة.
72+
=======
73+
Here, `height || 100` treats zero height as unset, same as `null`, `undefined` or any other falsy value. So the result is `100`.
74+
75+
The `height ?? 100` returns `100` only if `height` is exactly `null` or `undefined`. So the `alert` shows the height value `0` "as is".
76+
77+
Which behavior is better depends on a particular use case. When zero height is a valid value, then `??` is preferrable.
78+
>>>>>>> b52aa942a8e9b75ba8a65124c22593171e273bb6
7179
7280
## الأولوية
7381

1-js/03-code-quality/04-ninja-code/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ i = i ? i < 0 ? Math.max(0, len + i) : i : 0;
4343
منجز.
4444
```
4545

46+
<<<<<<< HEAD
4647
هناك طريقة أخرى للكتابه بشكل أسرع وهي استخدام أسماء المتغيرات ذات الحرف الواحد في كل مكان. مثل `a`, `b` او `c`.
48+
=======
49+
Another way to code shorter is to use single-letter variable names everywhere. Like `a`, `b` or `c`.
50+
>>>>>>> b52aa942a8e9b75ba8a65124c22593171e273bb6
4751
4852
يختفي متغير قصير في الكود مثل نينجا حقيقي في الغابة. لن يتمكن أحد من العثور عليه باستخدام "بحث" المحرر. وحتى لو فعل شخص ما ، فلن يتمكن من معرفه معني `A` او `B`
4953

1-js/05-data-types/10-destructuring-assignment/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ alert(`${guest} ${admin}`); // Pete Jane (successfully swapped!)
138138
Here we create a temporary array of two variables and immediately destructure it in swapped order.
139139

140140
We can swap more than two variables this way.
141-
```
141+
142142

143143
### The rest '...'
144144

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function byField(fieldName){
2+
return (a, b) => a[fieldName] > b[fieldName] ? 1 : -1;
3+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
function byField(fieldName){
2+
3+
// Your code goes here.
4+
5+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
describe("byField", function(){
2+
3+
let users = [
4+
{ name: "John", age: 20, surname: "Johnson" },
5+
{ name: "Pete", age: 18, surname: "Peterson" },
6+
{ name: "Ann", age: 19, surname: "Hathaway" },
7+
];
8+
9+
it("sorts users by name", function(){
10+
let nameSortedKey = [
11+
{ name: "Ann", age: 19, surname: "Hathaway" },
12+
{ name: "John", age: 20, surname: "Johnson"},
13+
{ name: "Pete", age: 18, surname: "Peterson" },
14+
];
15+
let nameSortedAnswer = users.sort(byField("name"));
16+
assert.deepEqual(nameSortedKey, nameSortedAnswer);
17+
});
18+
19+
it("sorts users by age", function(){
20+
let ageSortedKey = [
21+
{ name: "Pete", age: 18, surname: "Peterson" },
22+
{ name: "Ann", age: 19, surname: "Hathaway" },
23+
{ name: "John", age: 20, surname: "Johnson"},
24+
];
25+
let ageSortedAnswer = users.sort(byField("age"));
26+
assert.deepEqual(ageSortedKey, ageSortedKey);
27+
});
28+
29+
it("sorts users by surname", function(){
30+
let surnameSortedKey = [
31+
{ name: "Ann", age: 19, surname: "Hathaway" },
32+
{ name: "John", age: 20, surname: "Johnson"},
33+
{ name: "Pete", age: 18, surname: "Peterson" },
34+
];
35+
let surnameSortedAnswer = users.sort(byField("surname"));
36+
assert.deepEqual(surnameSortedAnswer, surnameSortedKey);
37+
});
38+
39+
});
Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1 @@
11

2-
3-
```js run
4-
let users = [
5-
{ name: "John", age: 20, surname: "Johnson" },
6-
{ name: "Pete", age: 18, surname: "Peterson" },
7-
{ name: "Ann", age: 19, surname: "Hathaway" }
8-
];
9-
10-
*!*
11-
function byField(field) {
12-
return (a, b) => a[field] > b[field] ? 1 : -1;
13-
}
14-
*/!*
15-
16-
users.sort(byField('name'));
17-
users.forEach(user => alert(user.name)); // Ann, John, Pete
18-
19-
users.sort(byField('age'));
20-
users.forEach(user => alert(user.name)); // Pete, Ann, John
21-
```
22-

1-js/08-prototypes/04-prototype-methods/article.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,15 @@ alert(rabbit.jumps); // true
5757
يمكننا استخدام `Object.create` للقيام بنسخ كائن بشكل أفضل من نسخ الخصائص باستخدام التكرار `for..in`:
5858

5959
```js
60+
<<<<<<< HEAD
6061
// كائن جديد مماثل تمامًا
6162
let clone = Object.create(
6263
Object.getPrototypeOf(obj),
6364
Object.getOwnPropertyDescriptors(obj)
6465
);
66+
=======
67+
let clone = Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
68+
>>>>>>> b52aa942a8e9b75ba8a65124c22593171e273bb6
6569
```
6670

6771
هذا الإستدعاء يقوم بإنشاء نسخه طبق الأصل من الكائن `obj` بما فيه من خصائص سواءًا كانت معدودة (enumerable) أم لا وكذلك الجالبات والمغيرات (getters & setters) -- كل شيئ وبالخاصية `[[Prototype]]` الصحيحة.

2-ui/3-event-details/6-pointer-events/article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Let's make a small overview, so that you understand the general picture and the
1010

1111
Then touch devices appeared. For the old code to work, they also generate mouse events. For instance, tapping generates `mousedown`. But mouse events were not good enough, as touch devices are more powerful in many aspects. For example, it's possible to touch multiple points at once, and mouse events don't have any properties for that.
1212

13-
- So touch events were introduced, such as `touchstart`, `touchend`, `touchmove`, that have touch-specific properties (we don't cover them in details here, because pointer events are event better).
13+
- So touch events were introduced, such as `touchstart`, `touchend`, `touchmove`, that have touch-specific properties (we don't cover them in detail here, because pointer events are even better).
1414

1515
Still, it wasn't enough, as there are many other devices, such as pens, that have their own features. Also, writing a code that listens both touch and mouse events was cumbersome.
1616

0 commit comments

Comments
 (0)