fix: converted single to triple backticks4 (#36231)
This commit is contained in:
@@ -20,10 +20,11 @@ localeTitle: استخدم Arrow Functions لكتابة الدالات المجه
|
|||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`const magic = () => {
|
```javascript
|
||||||
"use strict";
|
const magic = () => {
|
||||||
return new Date();
|
"use strict";
|
||||||
};
|
return new Date();
|
||||||
`
|
};
|
||||||
|
```
|
||||||
|
|
||||||
طالما أنك تخلصت من الكلمة الرئيسية `var` ، فأنت جيد.
|
طالما أنك تخلصت من الكلمة الرئيسية `var` ، فأنت جيد.
|
@@ -18,18 +18,19 @@ localeTitle: استخدم بناء جملة class لتعريف دالة منشئ
|
|||||||
|
|
||||||
## حل:
|
## حل:
|
||||||
|
|
||||||
`function makeClass() {
|
```javascript
|
||||||
"use strict";
|
function makeClass() {
|
||||||
/* Alter code below this line */
|
"use strict";
|
||||||
class Vegetable {
|
/* Alter code below this line */
|
||||||
constructor(name){
|
class Vegetable {
|
||||||
this.name = name;
|
constructor(name){
|
||||||
}
|
this.name = name;
|
||||||
}
|
}
|
||||||
/* Alter code above this line */
|
}
|
||||||
return Vegetable;
|
/* Alter code above this line */
|
||||||
}
|
return Vegetable;
|
||||||
`
|
}
|
||||||
|
```
|
||||||
|
|
||||||
\=======
|
\=======
|
||||||
|
|
||||||
|
@@ -12,5 +12,6 @@ localeTitle: استخدم Destructuring Assignment لتعيين متغيرات
|
|||||||
|
|
||||||
هنا هو الحل رمز:
|
هنا هو الحل رمز:
|
||||||
|
|
||||||
`const { tomorrow: { max: maxOfTomorrow } } = forecast;
|
```javascript
|
||||||
`
|
const { tomorrow: { max: maxOfTomorrow } } = forecast;
|
||||||
|
```
|
@@ -12,10 +12,11 @@ localeTitle: استخدم Destructuring Assignment لتعيين متغيرات
|
|||||||
|
|
||||||
# إعادة تعيين خصائص باستخدام deconstruction.
|
# إعادة تعيين خصائص باستخدام deconstruction.
|
||||||
|
|
||||||
`var basicOjb = {x: 40};
|
```javascript
|
||||||
//To reassign 'get the value of the x property of basicObj and place its value into bigX' in ES6:
|
var basicOjb = {x: 40};
|
||||||
const { x: bigX } = basicOjb;
|
//To reassign 'get the value of the x property of basicObj and place its value into bigX' in ES6:
|
||||||
consle.log(bigX) // ans = 40
|
const { x: bigX } = basicOjb;
|
||||||
`
|
consle.log(bigX) // ans = 40
|
||||||
|
```
|
||||||
|
|
||||||
ضع قيمة الخاصية الطول 'str' في len.
|
ضع قيمة الخاصية الطول 'str' في len.
|
@@ -14,18 +14,19 @@ localeTitle: استخدم Destructuring Assignment لتمرير كائن كمع
|
|||||||
|
|
||||||
## الحل 1:
|
## الحل 1:
|
||||||
|
|
||||||
`const half = (function() {
|
```javascript
|
||||||
"use strict"; // do not change this line
|
const half = (function() {
|
||||||
|
"use strict"; // do not change this line
|
||||||
// change code below this line
|
|
||||||
return function half({max, min}) {
|
// change code below this line
|
||||||
// use function argument destructuring
|
return function half({max, min}) {
|
||||||
return (max + min) / 2.0;
|
// use function argument destructuring
|
||||||
};
|
return (max + min) / 2.0;
|
||||||
// change code above this line
|
};
|
||||||
|
// change code above this line
|
||||||
})();
|
|
||||||
`
|
})();
|
||||||
|
```
|
||||||
|
|
||||||
لاحظ أننا ندمر `stats` لتمرير اثنين من صفاتها - `max` `min` - إلى الوظيفة. لا تنس تعديل بيان الإرجاع الثاني. تغيير `stats.max` إلى `max` ، وتغيير `stats.min` إلى `min` فقط.
|
لاحظ أننا ندمر `stats` لتمرير اثنين من صفاتها - `max` `min` - إلى الوظيفة. لا تنس تعديل بيان الإرجاع الثاني. تغيير `stats.max` إلى `max` ، وتغيير `stats.min` إلى `min` فقط.
|
||||||
|
|
||||||
@@ -33,15 +34,16 @@ localeTitle: استخدم Destructuring Assignment لتمرير كائن كمع
|
|||||||
|
|
||||||
هنا هو حل آخر يعمل. ليس الكثير من الاختلاف ، بخلاف حقيقة أن الوظيفة لا تملك اسمًا.
|
هنا هو حل آخر يعمل. ليس الكثير من الاختلاف ، بخلاف حقيقة أن الوظيفة لا تملك اسمًا.
|
||||||
|
|
||||||
`const half = (function() {
|
```javascript
|
||||||
"use strict"; // do not change this line
|
const half = (function() {
|
||||||
|
"use strict"; // do not change this line
|
||||||
// change code below this line
|
|
||||||
return (({max, min}) => {
|
// change code below this line
|
||||||
// use function argument destructuring
|
return (({max, min}) => {
|
||||||
return (max + min) / 2.0;
|
// use function argument destructuring
|
||||||
});
|
return (max + min) / 2.0;
|
||||||
// change code above this line
|
});
|
||||||
|
// change code above this line
|
||||||
})();
|
|
||||||
`
|
})();
|
||||||
|
```
|
@@ -20,48 +20,52 @@ localeTitle: استخدم Destructuring Assignment مع عامل التشغيل
|
|||||||
|
|
||||||
استخدم destructuring لإنشاء متغير `arr` .
|
استخدم destructuring لإنشاء متغير `arr` .
|
||||||
|
|
||||||
`function removeFirstTwo(list) {
|
```javascript
|
||||||
"use strict";
|
function removeFirstTwo(list) {
|
||||||
// change code below this line
|
"use strict";
|
||||||
const [arr] = list; // change this
|
// change code below this line
|
||||||
// change code above this line
|
const [arr] = list; // change this
|
||||||
return arr;
|
// change code above this line
|
||||||
}
|
return arr;
|
||||||
`
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## تلميح 2
|
## تلميح 2
|
||||||
|
|
||||||
انشر معلمة `list` في `arr` .
|
انشر معلمة `list` في `arr` .
|
||||||
|
|
||||||
`function removeFirstTwo(list) {
|
```javascript
|
||||||
"use strict";
|
function removeFirstTwo(list) {
|
||||||
// change code below this line
|
"use strict";
|
||||||
const [...arr] = list; // change this
|
// change code below this line
|
||||||
// change code above this line
|
const [...arr] = list; // change this
|
||||||
return arr;
|
// change code above this line
|
||||||
}
|
return arr;
|
||||||
`
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## تلميح 3
|
## تلميح 3
|
||||||
|
|
||||||
استبعاد أول عنصرين من صفيف `arr` مع `,,` .
|
استبعاد أول عنصرين من صفيف `arr` مع `,,` .
|
||||||
|
|
||||||
`function removeFirstTwo(list) {
|
```javascript
|
||||||
"use strict";
|
function removeFirstTwo(list) {
|
||||||
// change code below this line
|
"use strict";
|
||||||
const [,,...arr] = list; // change this
|
// change code below this line
|
||||||
// change code above this line
|
const [,,...arr] = list; // change this
|
||||||
return arr;
|
// change code above this line
|
||||||
}
|
return arr;
|
||||||
`
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## تنبيه المفسد - الحل إلى الأمام!
|
## تنبيه المفسد - الحل إلى الأمام!
|
||||||
|
|
||||||
`function removeFirstTwo(list) {
|
```javascript
|
||||||
"use strict";
|
function removeFirstTwo(list) {
|
||||||
// change code below this line
|
"use strict";
|
||||||
const [a, b, ...arr] = list;
|
// change code below this line
|
||||||
// change code above this line
|
const [a, b, ...arr] = list;
|
||||||
return arr;
|
// change code above this line
|
||||||
}
|
return arr;
|
||||||
`
|
}
|
||||||
|
```
|
@@ -16,7 +16,8 @@ localeTitle: استخدم التصدير لإعادة استخدام كتلة ت
|
|||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`"use strict";
|
```javascript
|
||||||
export const foo = "bar";
|
"use strict";
|
||||||
export const bar = "foo";
|
export const foo = "bar";
|
||||||
`
|
export const bar = "foo";
|
||||||
|
```
|
@@ -29,17 +29,20 @@ localeTitle: استخدم Spread Operator لتقييم Arrays في - مكان
|
|||||||
|
|
||||||
### 3 أمثلة سريعة
|
### 3 أمثلة سريعة
|
||||||
|
|
||||||
`let numbers = [-12, 160, 0, -3, 51];
|
```javascript
|
||||||
let minNum = Math.min.apply(null, numbers);
|
let numbers = [-12, 160, 0, -3, 51];
|
||||||
console.log(minNum);//-12
|
let minNum = Math.min.apply(null, numbers);
|
||||||
`
|
console.log(minNum);//-12
|
||||||
|
```
|
||||||
|
|
||||||
`let numbers = [-12, 160, 0, -3, 51];
|
```javascript
|
||||||
let minNum = Math.min(numbers);
|
let numbers = [-12, 160, 0, -3, 51];
|
||||||
console.log(minNum);//NaN
|
let minNum = Math.min(numbers);
|
||||||
`
|
console.log(minNum);//NaN
|
||||||
|
```
|
||||||
|
|
||||||
`let numbers = [-12, 160, 0, -3, 51];
|
```javascript
|
||||||
let minNum = Math.min(...numbers);
|
let numbers = [-12, 160, 0, -3, 51];
|
||||||
console.log(minNum);//-12
|
let minNum = Math.min(...numbers);
|
||||||
`
|
console.log(minNum);//-12
|
||||||
|
```
|
@@ -20,10 +20,11 @@ localeTitle: كتابة وظائف السهم مع المعلمات
|
|||||||
|
|
||||||
## حل:
|
## حل:
|
||||||
|
|
||||||
`const myConcat = (arr1, arr2) => {
|
```javascript
|
||||||
"use strict";
|
const myConcat = (arr1, arr2) => {
|
||||||
return arr1.concat(arr2);
|
"use strict";
|
||||||
};
|
return arr1.concat(arr2);
|
||||||
// test your code
|
};
|
||||||
console.log(myConcat([1, 2], [3, 4, 5]));
|
// test your code
|
||||||
`
|
console.log(myConcat([1, 2], [3, 4, 5]));
|
||||||
|
```
|
@@ -14,11 +14,12 @@ ES6 يجعل من السهل ، والخيال ، لكتابة وظائف الإ
|
|||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`const bicycle = {
|
```javascript
|
||||||
gear: 2,
|
const bicycle = {
|
||||||
setGear(newGear) {
|
gear: 2,
|
||||||
"use strict";
|
setGear(newGear) {
|
||||||
this.gear = newGear;
|
"use strict";
|
||||||
}
|
this.gear = newGear;
|
||||||
};
|
}
|
||||||
`
|
};
|
||||||
|
```
|
@@ -14,14 +14,15 @@ localeTitle: كتابة تعريفات كائن حرفي باستخدام حقو
|
|||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`const createPerson = (name, age, gender) => {
|
```javascript
|
||||||
"use strict";
|
const createPerson = (name, age, gender) => {
|
||||||
// change code below this line
|
"use strict";
|
||||||
return {
|
// change code below this line
|
||||||
name,
|
return {
|
||||||
age,
|
name,
|
||||||
gender
|
age,
|
||||||
};
|
gender
|
||||||
// change code above this line
|
};
|
||||||
};
|
// change code above this line
|
||||||
`
|
};
|
||||||
|
```
|
@@ -23,14 +23,15 @@ localeTitle: تطبيق برمجة وظيفية لتحويل السلاسل إل
|
|||||||
|
|
||||||
### حل بديل
|
### حل بديل
|
||||||
|
|
||||||
`// the global variable
|
```javascript
|
||||||
var globalTitle = "Winter Is Coming";
|
// the global variable
|
||||||
|
var globalTitle = "Winter Is Coming";
|
||||||
// Add your code below this line
|
|
||||||
function urlSlug(title) {
|
// Add your code below this line
|
||||||
return title.toLowerCase().trim().split(/\s+/).join('-');
|
function urlSlug(title) {
|
||||||
}
|
return title.toLowerCase().trim().split(/\s+/).join('-');
|
||||||
// Add your code above this line
|
}
|
||||||
|
// Add your code above this line
|
||||||
var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"
|
|
||||||
`
|
var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"
|
||||||
|
```
|
@@ -24,10 +24,11 @@ localeTitle: دمج صفيف في سلسلة باستخدام طريقة الا
|
|||||||
|
|
||||||
### حل:
|
### حل:
|
||||||
|
|
||||||
`function sentensify(str) {
|
```javascript
|
||||||
// Add your code below this line
|
function sentensify(str) {
|
||||||
return str.split(/\W/).join(' ');
|
// Add your code below this line
|
||||||
// Add your code above this line
|
return str.split(/\W/).join(' ');
|
||||||
}
|
// Add your code above this line
|
||||||
sentensify("May-the-force-be-with-you");
|
}
|
||||||
`
|
sentensify("May-the-force-be-with-you");
|
||||||
|
```
|
@@ -10,22 +10,23 @@ localeTitle: تنفيذ الخريطة على نموذج أولي
|
|||||||
|
|
||||||
ومن هناك ، يمكننا استخدام forEach أو for loop لإضافة عناصر إلى مصفوفة فارغة تم تعريفها بالفعل ، حيث نقوم بتعديل كل عنصر باستخدام طريقة رد الاتصال المحددة.
|
ومن هناك ، يمكننا استخدام forEach أو for loop لإضافة عناصر إلى مصفوفة فارغة تم تعريفها بالفعل ، حيث نقوم بتعديل كل عنصر باستخدام طريقة رد الاتصال المحددة.
|
||||||
|
|
||||||
`// the global Array
|
```javascript
|
||||||
var s = [23, 65, 98, 5];
|
// the global Array
|
||||||
|
var s = [23, 65, 98, 5];
|
||||||
Array.prototype.myMap = function(callback){
|
|
||||||
var newArray = [];
|
Array.prototype.myMap = function(callback){
|
||||||
// Add your code below this line
|
var newArray = [];
|
||||||
this.forEach(a => newArray.push(callback(a)));
|
// Add your code below this line
|
||||||
// Add your code above this line
|
this.forEach(a => newArray.push(callback(a)));
|
||||||
return newArray;
|
// Add your code above this line
|
||||||
|
return newArray;
|
||||||
};
|
|
||||||
|
};
|
||||||
var new_s = s.myMap(function(item){
|
|
||||||
return item * 2;
|
var new_s = s.myMap(function(item){
|
||||||
});
|
return item * 2;
|
||||||
`
|
});
|
||||||
|
```
|
||||||
|
|
||||||
### روابط مفيدة
|
### روابط مفيدة
|
||||||
|
|
||||||
|
@@ -4,22 +4,23 @@ localeTitle: تنفيذ مرشح طريقة على النموذج
|
|||||||
---
|
---
|
||||||
## تنفيذ مرشح طريقة على النموذج
|
## تنفيذ مرشح طريقة على النموذج
|
||||||
|
|
||||||
`// the global Array
|
```javascript
|
||||||
var s = [23, 65, 98, 5];
|
// the global Array
|
||||||
|
var s = [23, 65, 98, 5];
|
||||||
Array.prototype.myFilter = function(callback){
|
|
||||||
var newArray = [];
|
Array.prototype.myFilter = function(callback){
|
||||||
// Add your code below this line
|
var newArray = [];
|
||||||
this.forEach(function(x) {
|
// Add your code below this line
|
||||||
if (callback(x) == true) {
|
this.forEach(function(x) {
|
||||||
newArray.push(x);
|
if (callback(x) == true) {
|
||||||
}
|
newArray.push(x);
|
||||||
})
|
}
|
||||||
// Add your code above this line
|
})
|
||||||
return newArray;
|
// Add your code above this line
|
||||||
|
return newArray;
|
||||||
};
|
|
||||||
`
|
};
|
||||||
|
```
|
||||||
|
|
||||||
## حل آخر باستخدام looop!
|
## حل آخر باستخدام looop!
|
||||||
|
|
||||||
|
@@ -6,14 +6,15 @@ localeTitle: مقدمة في التجلي والتطبيق الجزئي
|
|||||||
|
|
||||||
### حل
|
### حل
|
||||||
|
|
||||||
`function add(x) {
|
```javascript
|
||||||
// Add your code below this line
|
function add(x) {
|
||||||
return function(y) {
|
// Add your code below this line
|
||||||
return function(z) {
|
return function(y) {
|
||||||
return x + y + z;
|
return function(z) {
|
||||||
}
|
return x + y + z;
|
||||||
}
|
}
|
||||||
// Add your code above this line
|
}
|
||||||
}
|
// Add your code above this line
|
||||||
add(10)(20)(30);
|
}
|
||||||
`
|
add(10)(20)(30);
|
||||||
|
```
|
@@ -13,31 +13,33 @@ localeTitle: المتغيرات العالمية ريفاكتور من الوظ
|
|||||||
|
|
||||||
## الحل 1
|
## الحل 1
|
||||||
|
|
||||||
`function add (arr, bookName) {
|
```javascript
|
||||||
let newArr = [...arr]; // Copy the bookList array to a new array.
|
function add (arr, bookName) {
|
||||||
newArr.push(bookName); // Add bookName parameter to the end of the new array.
|
let newArr = [...arr]; // Copy the bookList array to a new array.
|
||||||
return newArr; // Return the new array.
|
newArr.push(bookName); // Add bookName parameter to the end of the new array.
|
||||||
}
|
return newArr; // Return the new array.
|
||||||
|
}
|
||||||
function remove (arr, bookName) {
|
|
||||||
let newArr = [...arr]; // Copy the bookList array to a new array.
|
function remove (arr, bookName) {
|
||||||
if (newArr.indexOf(bookName) >= 0) { // Check whether the bookName parameter is in new array.
|
let newArr = [...arr]; // Copy the bookList array to a new array.
|
||||||
/.
|
if (newArr.indexOf(bookName) >= 0) { // Check whether the bookName parameter is in new array.
|
||||||
newArr.splice(newArr.indexOf(bookName), 1); // Remove the given paramater from the new array.
|
/.
|
||||||
return newArr; // Return the new array.
|
newArr.splice(newArr.indexOf(bookName), 1); // Remove the given paramater from the new array.
|
||||||
}
|
return newArr; // Return the new array.
|
||||||
}
|
}
|
||||||
`
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## الحل 2
|
## الحل 2
|
||||||
|
|
||||||
`function add (list,bookName) {
|
```javascript
|
||||||
return [...list, bookName];
|
function add (list,bookName) {
|
||||||
}
|
return [...list, bookName];
|
||||||
|
}
|
||||||
function remove (list,bookName) {
|
|
||||||
if (list.indexOf(bookName) >= 0) {
|
function remove (list,bookName) {
|
||||||
return list.filter((item) => item !== bookName);
|
if (list.indexOf(bookName) >= 0) {
|
||||||
}
|
return list.filter((item) => item !== bookName);
|
||||||
}
|
}
|
||||||
`
|
}
|
||||||
|
```
|
@@ -10,13 +10,14 @@ localeTitle: إرجاع صفيف Sorted دون تغيير في صفيف الأص
|
|||||||
|
|
||||||
### حل
|
### حل
|
||||||
|
|
||||||
`var globalArray = [5, 6, 3, 2, 9];
|
```javascript
|
||||||
function nonMutatingSort(arr) {
|
var globalArray = [5, 6, 3, 2, 9];
|
||||||
// Add your code below this line
|
function nonMutatingSort(arr) {
|
||||||
return [].concat(arr).sort(function(a, b) {
|
// Add your code below this line
|
||||||
return a - b;
|
return [].concat(arr).sort(function(a, b) {
|
||||||
});
|
return a - b;
|
||||||
// Add your code above this line
|
});
|
||||||
}
|
// Add your code above this line
|
||||||
nonMutatingSort(globalArray);
|
}
|
||||||
`
|
nonMutatingSort(globalArray);
|
||||||
|
```
|
@@ -12,20 +12,22 @@ localeTitle: عودة جزء من صفيف باستخدام طريقة شريح
|
|||||||
|
|
||||||
يمكن كتابة الدالة ببساطة عن طريق كتابة سطر واحد من التعليمات البرمجية - عبارة return. تمامًا كما في المثال المعطى ، قم `beginSlice` المصفوفة التي تأخذها الدالة كمعلمة باستخدام معلمات `beginSlice` و `endSlice` كمعلمات `endSlice` `slice()` . تذكر بنية طريقة `slice()` :
|
يمكن كتابة الدالة ببساطة عن طريق كتابة سطر واحد من التعليمات البرمجية - عبارة return. تمامًا كما في المثال المعطى ، قم `beginSlice` المصفوفة التي تأخذها الدالة كمعلمة باستخدام معلمات `beginSlice` و `endSlice` كمعلمات `endSlice` `slice()` . تذكر بنية طريقة `slice()` :
|
||||||
|
|
||||||
`var arr = ["Cat", "Dog", "Tiger", "Zebra", "Ant"];
|
```javascript
|
||||||
arr.slice([index-to-begin-slice] , [index-to-end-slice]);
|
var arr = ["Cat", "Dog", "Tiger", "Zebra", "Ant"];
|
||||||
`
|
arr.slice([index-to-begin-slice] , [index-to-end-slice]);
|
||||||
|
```
|
||||||
|
|
||||||
### حل
|
### حل
|
||||||
|
|
||||||
`function sliceArray(anim, beginSlice, endSlice) {
|
```javascript
|
||||||
// Add your code below this line
|
function sliceArray(anim, beginSlice, endSlice) {
|
||||||
return anim.slice(beginSlice, endSlice);
|
// Add your code below this line
|
||||||
// Add your code above this line
|
return anim.slice(beginSlice, endSlice);
|
||||||
}
|
// Add your code above this line
|
||||||
var inputAnim = ["Cat", "Dog", "Tiger", "Zebra", "Ant"];
|
}
|
||||||
sliceArray(inputAnim, 1, 3);
|
var inputAnim = ["Cat", "Dog", "Tiger", "Zebra", "Ant"];
|
||||||
`
|
sliceArray(inputAnim, 1, 3);
|
||||||
|
```
|
||||||
|
|
||||||
#### روابط ذات صلة:
|
#### روابط ذات صلة:
|
||||||
|
|
||||||
|
@@ -8,25 +8,27 @@ localeTitle: فرز صفيف أبجديا باستخدام طريقة الفرز
|
|||||||
|
|
||||||
في المثال المعطى ، نرى كيف نكتب دالة ستعيد مصفوفة جديدة بترتيب أبجدي معكوس.
|
في المثال المعطى ، نرى كيف نكتب دالة ستعيد مصفوفة جديدة بترتيب أبجدي معكوس.
|
||||||
|
|
||||||
`function reverseAlpha(arr) {
|
```javascript
|
||||||
return arr.sort(function(a, b) {
|
function reverseAlpha(arr) {
|
||||||
return a < b;
|
return arr.sort(function(a, b) {
|
||||||
});
|
return a < b;
|
||||||
}
|
});
|
||||||
reverseAlpha(['l', 'h', 'z', 'b', 's']);
|
}
|
||||||
// Returns ['z', 's', 'l', 'h', 'b']
|
reverseAlpha(['l', 'h', 'z', 'b', 's']);
|
||||||
`
|
// Returns ['z', 's', 'l', 'h', 'b']
|
||||||
|
```
|
||||||
|
|
||||||
باستخدام هذا المنطق ، ببساطة عكس هندسة وظيفة لإرجاع مجموعة جديدة بالترتيب الأبجدي.
|
باستخدام هذا المنطق ، ببساطة عكس هندسة وظيفة لإرجاع مجموعة جديدة بالترتيب الأبجدي.
|
||||||
|
|
||||||
### حل
|
### حل
|
||||||
|
|
||||||
`function alphabeticalOrder(arr) {
|
```javascript
|
||||||
// Add your code below this line
|
function alphabeticalOrder(arr) {
|
||||||
return arr.sort(function(a,b) {
|
// Add your code below this line
|
||||||
return a > b;
|
return arr.sort(function(a,b) {
|
||||||
});
|
return a > b;
|
||||||
// Add your code above this line
|
});
|
||||||
}
|
// Add your code above this line
|
||||||
alphabeticalOrder(["a", "d", "c", "a", "z", "g"]);
|
}
|
||||||
`
|
alphabeticalOrder(["a", "d", "c", "a", "z", "g"]);
|
||||||
|
```
|
@@ -12,10 +12,11 @@ localeTitle: تقسيم سلسلة في صفيف باستخدام طريقة ا
|
|||||||
|
|
||||||
### حل
|
### حل
|
||||||
|
|
||||||
`function splitify(str) {
|
```javascript
|
||||||
// Add your code below this line
|
function splitify(str) {
|
||||||
return str.split(/\W/);
|
// Add your code below this line
|
||||||
// Add your code above this line
|
return str.split(/\W/);
|
||||||
}
|
// Add your code above this line
|
||||||
splitify("Hello World,I-am code");
|
}
|
||||||
`
|
splitify("Hello World,I-am code");
|
||||||
|
```
|
@@ -29,12 +29,13 @@ localeTitle: استخدم كل أسلوب للتحقق من أن كل عنصر
|
|||||||
|
|
||||||
## حل بديل
|
## حل بديل
|
||||||
|
|
||||||
`function checkPositive(arr) {
|
```javascript
|
||||||
// Add your code below this line
|
function checkPositive(arr) {
|
||||||
return arr.every(function(value) {
|
// Add your code below this line
|
||||||
return value > 0;
|
return arr.every(function(value) {
|
||||||
});
|
return value > 0;
|
||||||
// Add your code above this line
|
});
|
||||||
}
|
// Add your code above this line
|
||||||
checkPositive([1, 2, 3, -4, 5]);
|
}
|
||||||
`
|
checkPositive([1, 2, 3, -4, 5]);
|
||||||
|
```
|
@@ -10,11 +10,12 @@ localeTitle: استخدم طريقة التصفية لاستخراج البيا
|
|||||||
|
|
||||||
### حل
|
### حل
|
||||||
|
|
||||||
`// Add your code below this line
|
```javascript
|
||||||
|
// Add your code below this line
|
||||||
var filteredList = watchList.map(function(e) {
|
|
||||||
return {title: e["Title"], rating: e["imdbRating"]}
|
var filteredList = watchList.map(function(e) {
|
||||||
}).filter((e) => e.rating >= 8);
|
return {title: e["Title"], rating: e["imdbRating"]}
|
||||||
|
}).filter((e) => e.rating >= 8);
|
||||||
console.log(filteredList);
|
|
||||||
`
|
console.log(filteredList);
|
||||||
|
```
|
@@ -14,8 +14,9 @@ localeTitle: استخدم بعض الأسلوب للتحقق من أن أي عن
|
|||||||
|
|
||||||
### حل:
|
### حل:
|
||||||
|
|
||||||
`function checkPositive(arr) {
|
```javascript
|
||||||
return arr.some((elem) => elem > 0);
|
function checkPositive(arr) {
|
||||||
}
|
return arr.some((elem) => elem > 0);
|
||||||
checkPositive([1, 2, 3, -4, 5]);
|
}
|
||||||
`
|
checkPositive([1, 2, 3, -4, 5]);
|
||||||
|
```
|
@@ -41,10 +41,11 @@ localeTitle: اصنع شخصا
|
|||||||
|
|
||||||
إذا كنت تواجه مشاكل في كتابة أساليب `setter` ، في ما يلي نموذج لأسلوب `set` :
|
إذا كنت تواجه مشاكل في كتابة أساليب `setter` ، في ما يلي نموذج لأسلوب `set` :
|
||||||
|
|
||||||
`this.setFullName = function(input) {
|
```js
|
||||||
// Insert your code here
|
this.setFullName = function(input) {
|
||||||
}
|
// Insert your code here
|
||||||
`
|
}
|
||||||
|
```
|
||||||
|
|
||||||
> _حاول أن تحل المشكلة الآن_
|
> _حاول أن تحل المشكلة الآن_
|
||||||
|
|
||||||
@@ -56,37 +57,38 @@ localeTitle: اصنع شخصا
|
|||||||
|
|
||||||
##  الحل الأساسي للكود:
|
##  الحل الأساسي للكود:
|
||||||
|
|
||||||
`var Person = function(firstAndLast) {
|
```js
|
||||||
var fullName = firstAndLast;
|
var Person = function(firstAndLast) {
|
||||||
|
var fullName = firstAndLast;
|
||||||
this.getFirstName = function() {
|
|
||||||
return fullName.split(" ")[0];
|
this.getFirstName = function() {
|
||||||
};
|
return fullName.split(" ")[0];
|
||||||
|
};
|
||||||
this.getLastName = function() {
|
|
||||||
return fullName.split(" ")[1];
|
this.getLastName = function() {
|
||||||
};
|
return fullName.split(" ")[1];
|
||||||
|
};
|
||||||
this.getFullName = function() {
|
|
||||||
return fullName;
|
this.getFullName = function() {
|
||||||
};
|
return fullName;
|
||||||
|
};
|
||||||
this.setFirstName = function(name) {
|
|
||||||
fullName = name + " " + fullName.split(" ")[1];
|
this.setFirstName = function(name) {
|
||||||
};
|
fullName = name + " " + fullName.split(" ")[1];
|
||||||
|
};
|
||||||
this.setLastName = function(name) {
|
|
||||||
fullName = fullName.split(" ")[0] + " " + name;
|
this.setLastName = function(name) {
|
||||||
};
|
fullName = fullName.split(" ")[0] + " " + name;
|
||||||
|
};
|
||||||
this.setFullName = function(name) {
|
|
||||||
fullName = name;
|
this.setFullName = function(name) {
|
||||||
};
|
fullName = name;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
var bob = new Person('Bob Ross');
|
|
||||||
bob.getFullName();
|
var bob = new Person('Bob Ross');
|
||||||
`
|
bob.getFullName();
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### شرح الشفرة:
|
### شرح الشفرة:
|
||||||
|
@@ -199,17 +199,18 @@ localeTitle: بحث واستبدال
|
|||||||
|
|
||||||
##  حل رمز متقدم البديل 2:
|
##  حل رمز متقدم البديل 2:
|
||||||
|
|
||||||
`function myReplace(str, before, after) {
|
```javascript
|
||||||
const myArr = str.split(' ');
|
function myReplace(str, before, after) {
|
||||||
const [wordToReplace] = myArr.filter(item => item === before);
|
const myArr = str.split(' ');
|
||||||
return wordToReplace[0].toUpperCase() !== wordToReplace[0]
|
const [wordToReplace] = myArr.filter(item => item === before);
|
||||||
? myArr.map(item => item === before ? after : item).join(' ')
|
return wordToReplace[0].toUpperCase() !== wordToReplace[0]
|
||||||
: myArr.map(item => item === before? after[0].toUpperCase() + after.slice(1) : item).join(' ');
|
? myArr.map(item => item === before ? after : item).join(' ')
|
||||||
}
|
: myArr.map(item => item === before? after[0].toUpperCase() + after.slice(1) : item).join(' ');
|
||||||
|
}
|
||||||
// test:
|
|
||||||
myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
|
// test:
|
||||||
`
|
myReplace("A quick brown fox jumped over the lazy dog", "jumped", "leaped");
|
||||||
|
```
|
||||||
|
|
||||||
#### روابط ذات صلة
|
#### روابط ذات صلة
|
||||||
|
|
||||||
|
@@ -100,8 +100,9 @@ localeTitle: تسعى وتدمر
|
|||||||
|
|
||||||
## الحل المتقدم للكود:
|
## الحل المتقدم للكود:
|
||||||
|
|
||||||
`const destroyer = (arr, ...args) => arr.filter(i => !args.includes(i));
|
```javascript
|
||||||
`
|
const destroyer = (arr, ...args) => arr.filter(i => !args.includes(i));
|
||||||
|
```
|
||||||
|
|
||||||
### شرح الشفرة:
|
### شرح الشفرة:
|
||||||
|
|
||||||
|
@@ -83,21 +83,22 @@ localeTitle: الاتحاد الفرز
|
|||||||
|
|
||||||
## بديلة حل رمز الأساسية
|
## بديلة حل رمز الأساسية
|
||||||
|
|
||||||
`function uniteUnique(arr) {
|
```javascript
|
||||||
var args = [...arguments];
|
function uniteUnique(arr) {
|
||||||
var result = [];
|
var args = [...arguments];
|
||||||
for(var i = 0; i < args.length; i++) {
|
var result = [];
|
||||||
for(var j = 0; j < args[i].length; j++) {
|
for(var i = 0; i < args.length; i++) {
|
||||||
if(!result.includes(args[i][j])) {
|
for(var j = 0; j < args[i].length; j++) {
|
||||||
result.push(args[i][j]);
|
if(!result.includes(args[i][j])) {
|
||||||
}
|
result.push(args[i][j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
}
|
||||||
}
|
return result;
|
||||||
|
}
|
||||||
uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
|
|
||||||
`
|
uniteUnique([1, 3, 2], [5, 2, 1, 4], [2, 1]);
|
||||||
|
```
|
||||||
|
|
||||||
##  حل الشفرة المتوسطة:
|
##  حل الشفرة المتوسطة:
|
||||||
|
|
||||||
|
@@ -8,30 +8,32 @@ localeTitle: إضافة طرق بعد الوراثة
|
|||||||
|
|
||||||
تمامًا كما في المثال التالي ، يجب إنشاء مثيل جديد لكائن - `Dog` - ويجب تعيين `prototype` .
|
تمامًا كما في المثال التالي ، يجب إنشاء مثيل جديد لكائن - `Dog` - ويجب تعيين `prototype` .
|
||||||
|
|
||||||
`function Bird() { }
|
```javascript
|
||||||
Bird.prototype = Object.create(Animal.prototype);
|
function Bird() { }
|
||||||
Bird.prototype.constructor = Bird;
|
Bird.prototype = Object.create(Animal.prototype);
|
||||||
`
|
Bird.prototype.constructor = Bird;
|
||||||
|
```
|
||||||
|
|
||||||
ثم يجب إضافة وظيفة جديدة - `bark()` - إلى نموذج الكلب.
|
ثم يجب إضافة وظيفة جديدة - `bark()` - إلى نموذج الكلب.
|
||||||
|
|
||||||
### حل
|
### حل
|
||||||
|
|
||||||
`function Animal() { }
|
```javascript
|
||||||
Animal.prototype.eat = function() { console.log("nom nom nom"); };
|
function Animal() { }
|
||||||
|
Animal.prototype.eat = function() { console.log("nom nom nom"); };
|
||||||
function Dog() { }
|
|
||||||
|
function Dog() { }
|
||||||
// Add your code below this line
|
|
||||||
Dog.prototype = Object.create(Animal.prototype);
|
// Add your code below this line
|
||||||
Dog.prototype.constructor = Dog;
|
Dog.prototype = Object.create(Animal.prototype);
|
||||||
Dog.prototype.bark = function() {
|
Dog.prototype.constructor = Dog;
|
||||||
console.log("Woof woof!");
|
Dog.prototype.bark = function() {
|
||||||
};
|
console.log("Woof woof!");
|
||||||
// Add your code above this line
|
};
|
||||||
|
// Add your code above this line
|
||||||
let beagle = new Dog();
|
|
||||||
|
let beagle = new Dog();
|
||||||
beagle.eat(); // Should print "nom nom nom"
|
|
||||||
beagle.bark(); // Should print "Woof!"
|
beagle.eat(); // Should print "nom nom nom"
|
||||||
`
|
beagle.bark(); // Should print "Woof!"
|
||||||
|
```
|
@@ -28,20 +28,21 @@ localeTitle: تغيير النموذج إلى كائن جديد
|
|||||||
|
|
||||||
## الحل 1:
|
## الحل 1:
|
||||||
|
|
||||||
`function Dog(name) {
|
```javascript
|
||||||
this.name = name;
|
function Dog(name) {
|
||||||
}
|
this.name = name;
|
||||||
Dog.prototype = {
|
}
|
||||||
// Add your code below this line
|
Dog.prototype = {
|
||||||
numLegs: 2,
|
// Add your code below this line
|
||||||
eat: function(){
|
numLegs: 2,
|
||||||
console.log('nom nom nom');
|
eat: function(){
|
||||||
},
|
console.log('nom nom nom');
|
||||||
describe: function(){
|
},
|
||||||
console.log("My name is " + this.name);
|
describe: function(){
|
||||||
}
|
console.log("My name is " + this.name);
|
||||||
}
|
}
|
||||||
`
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## شرح الشفرة:
|
## شرح الشفرة:
|
||||||
|
|
||||||
@@ -51,21 +52,22 @@ localeTitle: تغيير النموذج إلى كائن جديد
|
|||||||
|
|
||||||
## الحل 2:
|
## الحل 2:
|
||||||
|
|
||||||
`function Dog(name) {
|
```javascript
|
||||||
this.name = name;
|
function Dog(name) {
|
||||||
}
|
this.name = name;
|
||||||
|
}
|
||||||
Dog.prototype = {
|
|
||||||
// Add your code below this line
|
Dog.prototype = {
|
||||||
numLegs: 2,
|
// Add your code below this line
|
||||||
eat(){
|
numLegs: 2,
|
||||||
console.log('nom nom nom');
|
eat(){
|
||||||
},
|
console.log('nom nom nom');
|
||||||
describe(){
|
},
|
||||||
console.log("My name is " + this.name);
|
describe(){
|
||||||
}
|
console.log("My name is " + this.name);
|
||||||
};
|
}
|
||||||
`
|
};
|
||||||
|
```
|
||||||
|
|
||||||
## شرح الشفرة:
|
## شرح الشفرة:
|
||||||
|
|
||||||
|
@@ -10,8 +10,9 @@ localeTitle: قم بإنشاء كائن JavaScript أساسي
|
|||||||
|
|
||||||
### حل:
|
### حل:
|
||||||
|
|
||||||
`let dog = {
|
```javascript
|
||||||
name: "George",
|
let dog = {
|
||||||
numLegs: 4
|
name: "George",
|
||||||
};
|
numLegs: 4
|
||||||
`
|
};
|
||||||
|
```
|
@@ -19,13 +19,14 @@ localeTitle: إنشاء طريقة على كائن
|
|||||||
|
|
||||||
### حل:
|
### حل:
|
||||||
|
|
||||||
`let dog = {
|
```javascript
|
||||||
name: "Spot",
|
let dog = {
|
||||||
numLegs: 4,
|
name: "Spot",
|
||||||
sayLegs: function() {
|
numLegs: 4,
|
||||||
return "This dog has " + dog.numLegs + " legs.";
|
sayLegs: function() {
|
||||||
}
|
return "This dog has " + dog.numLegs + " legs.";
|
||||||
};
|
}
|
||||||
|
};
|
||||||
dog.sayLegs();
|
|
||||||
`
|
dog.sayLegs();
|
||||||
|
```
|
@@ -10,9 +10,10 @@ localeTitle: تحديد وظيفة منشئ
|
|||||||
|
|
||||||
### حل:
|
### حل:
|
||||||
|
|
||||||
`function Dog() {
|
```javascript
|
||||||
this.name = "Geogre",
|
function Dog() {
|
||||||
this.color = "White",
|
this.name = "Geogre",
|
||||||
this.numLegs = 4;
|
this.color = "White",
|
||||||
}
|
this.numLegs = 4;
|
||||||
`
|
}
|
||||||
|
```
|
@@ -10,10 +10,11 @@ localeTitle: تمديد البنائين لتلقي الحجج
|
|||||||
|
|
||||||
### حل:
|
### حل:
|
||||||
|
|
||||||
`function Dog(name, color) {
|
```javascript
|
||||||
this.name = name;
|
function Dog(name, color) {
|
||||||
this.color = color;
|
this.name = name;
|
||||||
this.numLegs = 4;
|
this.color = color;
|
||||||
}
|
this.numLegs = 4;
|
||||||
let terrier = new Dog("George","White");
|
}
|
||||||
`
|
let terrier = new Dog("George","White");
|
||||||
|
```
|
@@ -12,8 +12,9 @@ localeTitle: وراثة السلوكيات من Supertype
|
|||||||
|
|
||||||
السماح للحيوان = Object.create (Animal.prototype) ؛
|
السماح للحيوان = Object.create (Animal.prototype) ؛
|
||||||
|
|
||||||
`### Solution
|
```
|
||||||
`
|
### Solution
|
||||||
|
```
|
||||||
|
|
||||||
جافا سكريبت
|
جافا سكريبت
|
||||||
|
|
||||||
|
@@ -10,24 +10,25 @@ localeTitle: تكرار جميع الممتلكات
|
|||||||
|
|
||||||
### حل
|
### حل
|
||||||
|
|
||||||
`function Dog(name) {
|
```javascript
|
||||||
this.name = name;
|
function Dog(name) {
|
||||||
}
|
this.name = name;
|
||||||
|
}
|
||||||
Dog.prototype.numLegs = 4;
|
|
||||||
|
Dog.prototype.numLegs = 4;
|
||||||
let beagle = new Dog("Snoopy");
|
|
||||||
|
let beagle = new Dog("Snoopy");
|
||||||
let ownProps = [];
|
|
||||||
let prototypeProps = [];
|
let ownProps = [];
|
||||||
|
let prototypeProps = [];
|
||||||
// Add your code below this line
|
|
||||||
for (let property in beagle) {
|
// Add your code below this line
|
||||||
if(Dog.hasOwnProperty(property)) {
|
for (let property in beagle) {
|
||||||
ownProps.push(property)
|
if(Dog.hasOwnProperty(property)) {
|
||||||
}
|
ownProps.push(property)
|
||||||
else {
|
}
|
||||||
prototypeProps.push(property)
|
else {
|
||||||
}
|
prototypeProps.push(property)
|
||||||
}
|
}
|
||||||
`
|
}
|
||||||
|
```
|
@@ -10,11 +10,12 @@ localeTitle: جعل رمز أكثر قابلة لإعادة الاستخدام
|
|||||||
|
|
||||||
### حل:
|
### حل:
|
||||||
|
|
||||||
`let dog = {
|
```javascript
|
||||||
name: "Spot",
|
let dog = {
|
||||||
numLegs: 4,
|
name: "Spot",
|
||||||
sayLegs: function() {return "This dog has " + this.numLegs + " legs.";}
|
numLegs: 4,
|
||||||
};
|
sayLegs: function() {return "This dog has " + this.numLegs + " legs.";}
|
||||||
|
};
|
||||||
dog.sayLegs();
|
|
||||||
`
|
dog.sayLegs();
|
||||||
|
```
|
@@ -6,7 +6,8 @@ localeTitle: تجاوز الأساليب الموروثة
|
|||||||
|
|
||||||
# حل
|
# حل
|
||||||
|
|
||||||
`Penguin.prototype.fly = function() {
|
```javascript
|
||||||
return "Alas, this is a flightless bird.";
|
Penguin.prototype.fly = function() {
|
||||||
};
|
return "Alas, this is a flightless bird.";
|
||||||
`
|
};
|
||||||
|
```
|
@@ -8,16 +8,17 @@ localeTitle: تذكر تعيين الخاصية منشئ عند تغيير "ال
|
|||||||
|
|
||||||
# حل
|
# حل
|
||||||
|
|
||||||
`Dog.prototype = {
|
```javascript
|
||||||
|
Dog.prototype = {
|
||||||
constructor: Dog, // Solution
|
|
||||||
|
constructor: Dog, // Solution
|
||||||
numLegs: 2,
|
|
||||||
eat: function() {
|
numLegs: 2,
|
||||||
console.log("nom nom nom");
|
eat: function() {
|
||||||
},
|
console.log("nom nom nom");
|
||||||
describe: function() {
|
},
|
||||||
console.log("My name is " + this.name);
|
describe: function() {
|
||||||
}
|
console.log("My name is " + this.name);
|
||||||
};
|
}
|
||||||
`
|
};
|
||||||
|
```
|
@@ -8,22 +8,24 @@ localeTitle: إعادة تعيين منشئ Conherrated الخاصية
|
|||||||
|
|
||||||
تمت برمجة كائنات `duck` `beagle` لترث خصائص `supertypes` . للكتابة فوق هذين السطرين من التعليمات البرمجية يجب أن تتم كتابتها لتعيين المنشئين إلى المنشئين المطلوبين `Bird` و `Dog` . يوضح التعليمة البرمجية التالية كيف يمكن تحقيق ذلك.
|
تمت برمجة كائنات `duck` `beagle` لترث خصائص `supertypes` . للكتابة فوق هذين السطرين من التعليمات البرمجية يجب أن تتم كتابتها لتعيين المنشئين إلى المنشئين المطلوبين `Bird` و `Dog` . يوضح التعليمة البرمجية التالية كيف يمكن تحقيق ذلك.
|
||||||
|
|
||||||
`Bird.prototype.constructor = Bird;
|
```javascript
|
||||||
`
|
Bird.prototype.constructor = Bird;
|
||||||
|
```
|
||||||
|
|
||||||
### حل
|
### حل
|
||||||
|
|
||||||
`function Animal() { }
|
```javascript
|
||||||
function Bird() { }
|
function Animal() { }
|
||||||
function Dog() { }
|
function Bird() { }
|
||||||
|
function Dog() { }
|
||||||
Bird.prototype = Object.create(Animal.prototype);
|
|
||||||
Dog.prototype = Object.create(Animal.prototype);
|
Bird.prototype = Object.create(Animal.prototype);
|
||||||
|
Dog.prototype = Object.create(Animal.prototype);
|
||||||
// Add your code below this line
|
|
||||||
Bird.prototype.constructor = Bird;
|
// Add your code below this line
|
||||||
Dog.prototype.constructor = Dog;
|
Bird.prototype.constructor = Bird;
|
||||||
|
Dog.prototype.constructor = Dog;
|
||||||
let duck = new Bird();
|
|
||||||
let beagle = new Dog();
|
let duck = new Bird();
|
||||||
`
|
let beagle = new Dog();
|
||||||
|
```
|
@@ -8,25 +8,27 @@ localeTitle: قم بتعيين Prototype الخاص بالطفل إلى مثيل
|
|||||||
|
|
||||||
لا يختلف هذا التحدي عن التحدي الأخير ، حيث يجب عليك إنشاء كائن يرث من النوع `supertype` . فقط هذه المرة سوف يرث `Dog` الفرعي نوع `Animal` الفائق. ببساطة إنشاء مثيل جديد من `Dog.prototype` مثل المثال التالي.
|
لا يختلف هذا التحدي عن التحدي الأخير ، حيث يجب عليك إنشاء كائن يرث من النوع `supertype` . فقط هذه المرة سوف يرث `Dog` الفرعي نوع `Animal` الفائق. ببساطة إنشاء مثيل جديد من `Dog.prototype` مثل المثال التالي.
|
||||||
|
|
||||||
`Bird.prototype = Object.create(Animal.prototype);
|
```javascript
|
||||||
`
|
Bird.prototype = Object.create(Animal.prototype);
|
||||||
|
```
|
||||||
|
|
||||||
### حل
|
### حل
|
||||||
|
|
||||||
`function Animal() { }
|
```javascript
|
||||||
|
function Animal() { }
|
||||||
Animal.prototype = {
|
|
||||||
constructor: Animal,
|
Animal.prototype = {
|
||||||
eat: function() {
|
constructor: Animal,
|
||||||
console.log("nom nom nom");
|
eat: function() {
|
||||||
}
|
console.log("nom nom nom");
|
||||||
};
|
}
|
||||||
|
};
|
||||||
function Dog() { }
|
|
||||||
|
function Dog() { }
|
||||||
// Add your code below this line
|
|
||||||
Dog.prototype = Object.create(Animal.prototype);
|
// Add your code below this line
|
||||||
|
Dog.prototype = Object.create(Animal.prototype);
|
||||||
let beagle = new Dog();
|
|
||||||
beagle.eat(); // Should print "nom nom nom"
|
let beagle = new Dog();
|
||||||
`
|
beagle.eat(); // Should print "nom nom nom"
|
||||||
|
```
|
@@ -12,12 +12,13 @@ localeTitle: فهم خصائص خاصة
|
|||||||
|
|
||||||
### حل:
|
### حل:
|
||||||
|
|
||||||
`let canary = new Bird("Tweety");
|
```javascript
|
||||||
let ownProps = [];
|
let canary = new Bird("Tweety");
|
||||||
// Add your code below this line
|
let ownProps = [];
|
||||||
for(let property in canary) {
|
// Add your code below this line
|
||||||
if(canary.hasOwnProperty(property)) {
|
for(let property in canary) {
|
||||||
ownProps.push(property);
|
if(canary.hasOwnProperty(property)) {
|
||||||
}
|
ownProps.push(property);
|
||||||
}
|
}
|
||||||
`
|
}
|
||||||
|
```
|
@@ -10,17 +10,18 @@ localeTitle: فهم خاصية منشئ
|
|||||||
|
|
||||||
### حل
|
### حل
|
||||||
|
|
||||||
`function Dog(name) {
|
```javascript
|
||||||
this.name = name;
|
function Dog(name) {
|
||||||
}
|
this.name = name;
|
||||||
|
}
|
||||||
// Add your code below this line
|
|
||||||
function joinDogFraternity(candidate) {
|
// Add your code below this line
|
||||||
if(candidate.constructor === Dog) {
|
function joinDogFraternity(candidate) {
|
||||||
return true;
|
if(candidate.constructor === Dog) {
|
||||||
}
|
return true;
|
||||||
else {
|
}
|
||||||
return false;
|
else {
|
||||||
}
|
return false;
|
||||||
}
|
}
|
||||||
`
|
}
|
||||||
|
```
|
@@ -10,7 +10,8 @@ localeTitle: فهم تعبير الدالة المستحثة فوراً (IIFE)
|
|||||||
|
|
||||||
### حل
|
### حل
|
||||||
|
|
||||||
`(function() {
|
```javascript
|
||||||
console.log("A cozy nest is ready");
|
(function() {
|
||||||
})();
|
console.log("A cozy nest is ready");
|
||||||
`
|
})();
|
||||||
|
```
|
@@ -10,11 +10,12 @@ localeTitle: استخدم منشئ لإنشاء كائنات
|
|||||||
|
|
||||||
### حل:
|
### حل:
|
||||||
|
|
||||||
`function Dog() {
|
```javascript
|
||||||
this.name = "Rupert";
|
function Dog() {
|
||||||
this.color = "brown";
|
this.name = "Rupert";
|
||||||
this.numLegs = 4;
|
this.color = "brown";
|
||||||
}
|
this.numLegs = 4;
|
||||||
// Add your code below this line
|
}
|
||||||
let hound = new Dog();
|
// Add your code below this line
|
||||||
`
|
let hound = new Dog();
|
||||||
|
```
|
@@ -10,22 +10,23 @@ localeTitle: استخدم Mixin لإضافة سلوك شائع بين الكائ
|
|||||||
|
|
||||||
### حل
|
### حل
|
||||||
|
|
||||||
`let bird = {
|
```javascript
|
||||||
name: "Donald",
|
let bird = {
|
||||||
numLegs: 2
|
name: "Donald",
|
||||||
};
|
numLegs: 2
|
||||||
|
};
|
||||||
let boat = {
|
|
||||||
name: "Warrior",
|
let boat = {
|
||||||
type: "race-boat"
|
name: "Warrior",
|
||||||
};
|
type: "race-boat"
|
||||||
|
};
|
||||||
// Add your code below this line
|
|
||||||
let glideMixin = function(obj) {
|
// Add your code below this line
|
||||||
obj.glide = function() {
|
let glideMixin = function(obj) {
|
||||||
console.log("Gliding!");
|
obj.glide = function() {
|
||||||
}
|
console.log("Gliding!");
|
||||||
};
|
}
|
||||||
glideMixin(bird);
|
};
|
||||||
glideMixin(boat);
|
glideMixin(bird);
|
||||||
`
|
glideMixin(boat);
|
||||||
|
```
|
@@ -8,35 +8,37 @@ localeTitle: استخدم IIFE لإنشاء وحدة نمطية
|
|||||||
|
|
||||||
يجب أن تكون ملفوفة في كلا `Mixin` 's في `funModule` جديدة لذا نقطة بداية esay للتعليق خارج الكود حتى الآن.
|
يجب أن تكون ملفوفة في كلا `Mixin` 's في `funModule` جديدة لذا نقطة بداية esay للتعليق خارج الكود حتى الآن.
|
||||||
|
|
||||||
`/*let isCuteMixin = function(obj) {
|
```javascript
|
||||||
obj.isCute = function() {
|
/*let isCuteMixin = function(obj) {
|
||||||
return true;
|
obj.isCute = function() {
|
||||||
};
|
return true;
|
||||||
};
|
};
|
||||||
let singMixin = function(obj) {
|
};
|
||||||
obj.sing = function() {
|
let singMixin = function(obj) {
|
||||||
console.log("Singing to an awesome tune");
|
obj.sing = function() {
|
||||||
};
|
console.log("Singing to an awesome tune");
|
||||||
};
|
};
|
||||||
*/
|
};
|
||||||
`
|
*/
|
||||||
|
```
|
||||||
|
|
||||||
ثم أدناه ابدأ بكتابة كود `funModule` الجديد. داخل الوحدة النمطية الجديدة ، تحتاج إلى كتابة بيان إرجاع لإرجاع كتل التعليمات البرمجية `Mixin` . ما عليك سوى نسخ كل من الكود الأصلي لكتل `Mixin` إلى كود الوحدة الجديدة ، ولكن تذكر أن تفصل كل من المزيج مع `,`
|
ثم أدناه ابدأ بكتابة كود `funModule` الجديد. داخل الوحدة النمطية الجديدة ، تحتاج إلى كتابة بيان إرجاع لإرجاع كتل التعليمات البرمجية `Mixin` . ما عليك سوى نسخ كل من الكود الأصلي لكتل `Mixin` إلى كود الوحدة الجديدة ، ولكن تذكر أن تفصل كل من المزيج مع `,`
|
||||||
|
|
||||||
### حل
|
### حل
|
||||||
|
|
||||||
`let funModule = (function() {
|
```javascript
|
||||||
return {
|
let funModule = (function() {
|
||||||
isCuteMixin: function(obj) {
|
return {
|
||||||
obj.isCute = function() {
|
isCuteMixin: function(obj) {
|
||||||
return true;
|
obj.isCute = function() {
|
||||||
};
|
return true;
|
||||||
},
|
};
|
||||||
singMixin: function(obj) {
|
},
|
||||||
obj.sing = function() {
|
singMixin: function(obj) {
|
||||||
console.log("Singing to an awesome tune");
|
obj.sing = function() {
|
||||||
};
|
console.log("Singing to an awesome tune");
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
})();
|
}
|
||||||
`
|
})();
|
||||||
|
```
|
@@ -8,23 +8,25 @@ localeTitle: استخدم Dot Notation للوصول إلى خصائص كائن
|
|||||||
|
|
||||||
ستقوم التعليمة البرمجية التالية ببساطة طباعة `property1` من كائن `obj` .
|
ستقوم التعليمة البرمجية التالية ببساطة طباعة `property1` من كائن `obj` .
|
||||||
|
|
||||||
`let obj = {
|
```javascript
|
||||||
property1 = 1,
|
let obj = {
|
||||||
property2 = 2
|
property1 = 1,
|
||||||
};
|
property2 = 2
|
||||||
|
};
|
||||||
console.log(obj.property1);
|
|
||||||
`
|
console.log(obj.property1);
|
||||||
|
```
|
||||||
|
|
||||||
باتباع هذا المنطق ، استخدم عملية `console.log` لطباعة كل من `property1` و `property2` على الشاشة.
|
باتباع هذا المنطق ، استخدم عملية `console.log` لطباعة كل من `property1` و `property2` على الشاشة.
|
||||||
|
|
||||||
### حل:
|
### حل:
|
||||||
|
|
||||||
`let dog = {
|
```javascript
|
||||||
name: "Spot",
|
let dog = {
|
||||||
numLegs: 4
|
name: "Spot",
|
||||||
};
|
numLegs: 4
|
||||||
// Add your code below this line
|
};
|
||||||
console.log(dog.name);
|
// Add your code below this line
|
||||||
console.log(dog.numLegs);
|
console.log(dog.name);
|
||||||
`
|
console.log(dog.numLegs);
|
||||||
|
```
|
@@ -8,28 +8,29 @@ localeTitle: استخدام الوراثة حتى لا تكرر نفسك
|
|||||||
|
|
||||||
قم بإزالة طريقة "تناول الطعام" من Cat.prototype و Bear.prototype وأضفها إلى Animal.prototype.
|
قم بإزالة طريقة "تناول الطعام" من Cat.prototype و Bear.prototype وأضفها إلى Animal.prototype.
|
||||||
|
|
||||||
`function Cat(name) {
|
```javascript
|
||||||
this.name = name;
|
function Cat(name) {
|
||||||
};
|
this.name = name;
|
||||||
|
};
|
||||||
Cat.prototype = {
|
|
||||||
constructor: Cat
|
Cat.prototype = {
|
||||||
};
|
constructor: Cat
|
||||||
|
};
|
||||||
function Bear(name) {
|
|
||||||
this.name = name;
|
function Bear(name) {
|
||||||
};
|
this.name = name;
|
||||||
|
};
|
||||||
Bear.prototype = {
|
|
||||||
constructor: Bear
|
Bear.prototype = {
|
||||||
};
|
constructor: Bear
|
||||||
|
};
|
||||||
function Animal() { };
|
|
||||||
|
function Animal() { };
|
||||||
Animal.prototype = {
|
|
||||||
constructor: Animal,
|
Animal.prototype = {
|
||||||
eat: function() {
|
constructor: Animal,
|
||||||
console.log("nom nom nom");
|
eat: function() {
|
||||||
}
|
console.log("nom nom nom");
|
||||||
};
|
}
|
||||||
`
|
};
|
||||||
|
```
|
@@ -10,19 +10,21 @@ localeTitle: استخدم خصائص النموذج لتخفيض قانون مك
|
|||||||
|
|
||||||
#### مثال:
|
#### مثال:
|
||||||
|
|
||||||
`Obj.prototype.newProperty = "New Property!";
|
```javascript
|
||||||
`
|
Obj.prototype.newProperty = "New Property!";
|
||||||
|
```
|
||||||
|
|
||||||
باستخدام هذا المنطق ، ببساطة إنشاء خاصية `prototype` جديد لـ `numLegs` . يمكن تمرير حالات الاختبار عن طريق استبدال كائن `Bird` بكائن `Dog` في المثال المعطى - `Bird.prototype.numLegs = 2;`
|
باستخدام هذا المنطق ، ببساطة إنشاء خاصية `prototype` جديد لـ `numLegs` . يمكن تمرير حالات الاختبار عن طريق استبدال كائن `Bird` بكائن `Dog` في المثال المعطى - `Bird.prototype.numLegs = 2;`
|
||||||
|
|
||||||
### حل:
|
### حل:
|
||||||
|
|
||||||
`function Dog(name) {
|
```javascript
|
||||||
this.name = name;
|
function Dog(name) {
|
||||||
}
|
this.name = name;
|
||||||
|
}
|
||||||
Dog.prototype.numLegs = 4;
|
|
||||||
|
Dog.prototype.numLegs = 4;
|
||||||
// Add your code above this line
|
|
||||||
let beagle = new Dog("Snoopy");
|
// Add your code above this line
|
||||||
`
|
let beagle = new Dog("Snoopy");
|
||||||
|
```
|
@@ -10,20 +10,22 @@ localeTitle: تحقق من Constructor كائن مع instanceof
|
|||||||
|
|
||||||
#### مثال:
|
#### مثال:
|
||||||
|
|
||||||
`let hound = new Dog();
|
```javascript
|
||||||
`
|
let hound = new Dog();
|
||||||
|
```
|
||||||
|
|
||||||
تذكر أن تعطي الدالة `House` معلمة لتهيئة عدد الغرف. ثم ببساطة استدعاء العامل `instanceof` للعودة حقيقية على منزلك الجديد.
|
تذكر أن تعطي الدالة `House` معلمة لتهيئة عدد الغرف. ثم ببساطة استدعاء العامل `instanceof` للعودة حقيقية على منزلك الجديد.
|
||||||
|
|
||||||
### حل:
|
### حل:
|
||||||
|
|
||||||
`/* jshint expr: true */
|
```javascript
|
||||||
|
/* jshint expr: true */
|
||||||
function House(numBedrooms) {
|
|
||||||
this.numBedrooms = numBedrooms;
|
function House(numBedrooms) {
|
||||||
}
|
this.numBedrooms = numBedrooms;
|
||||||
|
}
|
||||||
// Add your code below this line
|
|
||||||
let myHouse = new House(5);
|
// Add your code below this line
|
||||||
myHouse instanceof House;
|
let myHouse = new House(5);
|
||||||
`
|
myHouse instanceof House;
|
||||||
|
```
|
@@ -18,7 +18,8 @@ localeTitle: استخراج مباريات
|
|||||||
|
|
||||||
## حل:
|
## حل:
|
||||||
|
|
||||||
`let extractStr = "Extract the word 'coding' from this string.";
|
```javascript
|
||||||
let codingRegex = /coding/;
|
let extractStr = "Extract the word 'coding' from this string.";
|
||||||
let result = extractStr.match(codingRegex);
|
let codingRegex = /coding/;
|
||||||
`
|
let result = extractStr.match(codingRegex);
|
||||||
|
```
|
@@ -10,7 +10,8 @@ localeTitle: العثور على شخصيات مع مطابقة كسول
|
|||||||
|
|
||||||
#### حل:
|
#### حل:
|
||||||
|
|
||||||
`let text = "<h1>Winter is coming</h1>";
|
```js
|
||||||
let myRegex = /<h1>?/; // it's the answer!
|
let text = "<h1>Winter is coming</h1>";
|
||||||
let result = text.match(myRegex);
|
let myRegex = /<h1>?/; // it's the answer!
|
||||||
`
|
let result = text.match(myRegex);
|
||||||
|
```
|
@@ -18,7 +18,8 @@ localeTitle: العثور على أكثر من المباراة الأولى
|
|||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`let twinkleStar = "Twinkle, twinkle, little star";
|
```javascript
|
||||||
let starRegex = /twinkle/gi;
|
let twinkleStar = "Twinkle, twinkle, little star";
|
||||||
let result = twinkleStar.match(starRegex);
|
let starRegex = /twinkle/gi;
|
||||||
`
|
let result = twinkleStar.match(starRegex);
|
||||||
|
```
|
@@ -21,17 +21,19 @@ localeTitle: العثور على واحد أو أكثر من المجرمين ف
|
|||||||
|
|
||||||
هل تستخدم علامة "+" في تعبيرك العادي؟
|
هل تستخدم علامة "+" في تعبيرك العادي؟
|
||||||
|
|
||||||
`let regexp = /E+/; // returns E, EE, EEE patterns
|
```javascript
|
||||||
`
|
let regexp = /E+/; // returns E, EE, EEE patterns
|
||||||
|
```
|
||||||
|
|
||||||
### تحذير المفسد - الحل إلى الأمام
|
### تحذير المفسد - الحل إلى الأمام
|
||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`let crowd = 'P1P2P3P4P5P6CCCP7P8P9';
|
```javascript
|
||||||
|
let crowd = 'P1P2P3P4P5P6CCCP7P8P9';
|
||||||
let reCriminals = /C+/; // Change this line
|
|
||||||
|
let reCriminals = /C+/; // Change this line
|
||||||
let matchedCriminals = crowd.match(reCriminals);
|
|
||||||
console.log(matchedCriminals);
|
let matchedCriminals = crowd.match(reCriminals);
|
||||||
`
|
console.log(matchedCriminals);
|
||||||
|
```
|
@@ -14,7 +14,8 @@ localeTitle: تجاهل حالة أثناء المطابقة
|
|||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`let myString = "freeCodeCamp";
|
```javascript
|
||||||
let fccRegex = /freeCodeCamp/i;
|
let myString = "freeCodeCamp";
|
||||||
let result = fccRegex.test(myString);
|
let fccRegex = /freeCodeCamp/i;
|
||||||
`
|
let result = fccRegex.test(myString);
|
||||||
|
```
|
@@ -14,7 +14,8 @@ localeTitle: تطابق سلسلة حرفية مع الاحتمالات المخ
|
|||||||
|
|
||||||
## حل:
|
## حل:
|
||||||
|
|
||||||
`let petString = "James has a pet cat.";
|
```javascriot
|
||||||
let petRegex = /dog|cat|bird|fish/;
|
let petString = "James has a pet cat.";
|
||||||
let result = petRegex.test(petString);
|
let petRegex = /dog|cat|bird|fish/;
|
||||||
`
|
let result = petRegex.test(petString);
|
||||||
|
```
|
@@ -16,8 +16,9 @@ localeTitle: المباراة جميع غير الارقام
|
|||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`let noNumRegex = /\D/g;
|
```javascript
|
||||||
`
|
let noNumRegex = /\D/g;
|
||||||
|
```
|
||||||
|
|
||||||
## تفسير
|
## تفسير
|
||||||
|
|
||||||
|
@@ -16,8 +16,9 @@ localeTitle: تطابق جميع الأرقام
|
|||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`let numRegex = /\d/g;
|
```javascript
|
||||||
`
|
let numRegex = /\d/g;
|
||||||
|
```
|
||||||
|
|
||||||
## تفسير
|
## تفسير
|
||||||
|
|
||||||
|
@@ -14,10 +14,11 @@ localeTitle: تطابق أي شيء مع فترة أحرف البدل
|
|||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`let exampleStr = "Let's have fun with regular expressions!";
|
```javascript
|
||||||
let unRegex = /.un/; // Change this line
|
let exampleStr = "Let's have fun with regular expressions!";
|
||||||
let result = unRegex.test(exampleStr);
|
let unRegex = /.un/; // Change this line
|
||||||
`
|
let result = unRegex.test(exampleStr);
|
||||||
|
```
|
||||||
|
|
||||||
## كسبلايناتيون
|
## كسبلايناتيون
|
||||||
|
|
||||||
|
@@ -12,9 +12,10 @@ localeTitle: مباراة بداية أنماط سلسلة
|
|||||||
|
|
||||||
جرِّب محيطك المعتاد بالأشرطة المائلة
|
جرِّب محيطك المعتاد بالأشرطة المائلة
|
||||||
|
|
||||||
`let testExp = /^test/;
|
```javascript
|
||||||
// returns true or false depending on whether test is found in the beginning of the string
|
let testExp = /^test/;
|
||||||
`
|
// returns true or false depending on whether test is found in the beginning of the string
|
||||||
|
```
|
||||||
|
|
||||||
### تلميح 2:
|
### تلميح 2:
|
||||||
|
|
||||||
@@ -24,7 +25,8 @@ localeTitle: مباراة بداية أنماط سلسلة
|
|||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`let rickyAndCal = "Cal and Ricky both like racing.";
|
```javascript
|
||||||
let calRegex = /^Cal/; // Change this line
|
let rickyAndCal = "Cal and Ricky both like racing.";
|
||||||
let result = calRegex.test(rickyAndCal);
|
let calRegex = /^Cal/; // Change this line
|
||||||
`
|
let result = calRegex.test(rickyAndCal);
|
||||||
|
```
|
@@ -6,22 +6,24 @@ localeTitle: مطابقة الأحرف التي تحدث Zero أو أوقات إ
|
|||||||
|
|
||||||
لا يجب أن يحدث أي حرف في تعبير regex يتبعه `*` في السلسلة التي تم اختبارها ، في حين يجب أن يظهر أي حرف في تعبير regex متبوعًا بـ `+` في سلسلة واحدة على الأقل ، كما هو موضح أدناه ،
|
لا يجب أن يحدث أي حرف في تعبير regex يتبعه `*` في السلسلة التي تم اختبارها ، في حين يجب أن يظهر أي حرف في تعبير regex متبوعًا بـ `+` في سلسلة واحدة على الأقل ، كما هو موضح أدناه ،
|
||||||
|
|
||||||
`let phrase = "ba humbug";
|
```javascript
|
||||||
|
let phrase = "ba humbug";
|
||||||
let regexPlus = /bah+/;
|
|
||||||
let regexStar = /bah*/;
|
let regexPlus = /bah+/;
|
||||||
|
let regexStar = /bah*/;
|
||||||
regexPlus.test(phrase); // returns false
|
|
||||||
regexStar.test(phrase); // returns true
|
regexPlus.test(phrase); // returns false
|
||||||
`
|
regexStar.test(phrase); // returns true
|
||||||
|
```
|
||||||
|
|
||||||
كلاهما يسمحان بأي عدد من الأحداث من نفس الحرف في صف ، على سبيل المثال ،
|
كلاهما يسمحان بأي عدد من الأحداث من نفس الحرف في صف ، على سبيل المثال ،
|
||||||
|
|
||||||
`let phrase = "wooooow look at that!";
|
```javascript
|
||||||
|
let phrase = "wooooow look at that!";
|
||||||
let regexPlus = /wo+w/;
|
|
||||||
let regexStar = /wo*w/;
|
let regexPlus = /wo+w/;
|
||||||
|
let regexStar = /wo*w/;
|
||||||
regexPlus.test(phrase); // returns true
|
|
||||||
regexStar.test(phrase); // returns true
|
regexPlus.test(phrase); // returns true
|
||||||
`
|
regexStar.test(phrase); // returns true
|
||||||
|
```
|
@@ -16,7 +16,8 @@ localeTitle: المباراة الحرفيه الاوتار
|
|||||||
|
|
||||||
## حل:
|
## حل:
|
||||||
|
|
||||||
`let waldoIsHiding = "Somewhere Waldo is hiding in this text.";
|
```javascript
|
||||||
let waldoRegex = /Waldo/; // Change this line
|
let waldoIsHiding = "Somewhere Waldo is hiding in this text.";
|
||||||
let result = waldoRegex.test(waldoIsHiding);
|
let waldoRegex = /Waldo/; // Change this line
|
||||||
`
|
let result = waldoRegex.test(waldoIsHiding);
|
||||||
|
```
|
@@ -21,16 +21,18 @@ localeTitle: أرقام المباراة ورسائل الأبجدية
|
|||||||
|
|
||||||
هل تذكر تمكين إشارات regexp مثل "i" لتجاهل الحالة و "g" لإرجاع قيم متعددة؟ إذا كان الأمر كذلك ، فهل تقوم بتضمين كل من مطابقة الأحرف للأرقام والحروف؟
|
هل تذكر تمكين إشارات regexp مثل "i" لتجاهل الحالة و "g" لإرجاع قيم متعددة؟ إذا كان الأمر كذلك ، فهل تقوم بتضمين كل من مطابقة الأحرف للأرقام والحروف؟
|
||||||
|
|
||||||
`let regexp = /[a-z1-100]/ig
|
```javascript
|
||||||
// above code returns all characters from A to Z, along with all numbers from 1 to 100
|
let regexp = /[a-z1-100]/ig
|
||||||
// this includes the letter A and Z and the numbers 1 and 100
|
// above code returns all characters from A to Z, along with all numbers from 1 to 100
|
||||||
`
|
// this includes the letter A and Z and the numbers 1 and 100
|
||||||
|
```
|
||||||
|
|
||||||
### تنبيه المفسد - الحل إلى الأمام
|
### تنبيه المفسد - الحل إلى الأمام
|
||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`let quoteSample = "Blueberry 3.141592653s are delicious.";
|
```javascript
|
||||||
let myRegex = /[h-s2-6]/ig; // Change this line
|
let quoteSample = "Blueberry 3.141592653s are delicious.";
|
||||||
let result = quoteSample.match(myRegex); // Change this line
|
let myRegex = /[h-s2-6]/ig; // Change this line
|
||||||
`
|
let result = quoteSample.match(myRegex); // Change this line
|
||||||
|
```
|
@@ -20,7 +20,8 @@ localeTitle: تطابق شخصية واحدة مع إمكانيات متعددة
|
|||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
|
```javascript
|
||||||
let vowelRegex = /[aeiou]/ig; // Change this line
|
let quoteSample = "Beware of bugs in the above code; I have only proved it correct, not tried it.";
|
||||||
let result = quoteSample.match(vowelRegex); // Change this line
|
let vowelRegex = /[aeiou]/ig; // Change this line
|
||||||
`
|
let result = quoteSample.match(vowelRegex); // Change this line
|
||||||
|
```
|
@@ -23,14 +23,16 @@ localeTitle: مطابقة أحرف مفردة غير محددة
|
|||||||
|
|
||||||
تأكد من التحقق مما إذا كان نطاق الأرقام صحيحًا - يطالبنا التحدي بإنهاء جميع الأرقام من 0 إلى 99. يمكن القيام بذلك باستخدام علامة الإبطال السلبي الموضوعة مباشرة بعد أول شريحة افتتاحية من كلمة regexp الخاصة بك.
|
تأكد من التحقق مما إذا كان نطاق الأرقام صحيحًا - يطالبنا التحدي بإنهاء جميع الأرقام من 0 إلى 99. يمكن القيام بذلك باستخدام علامة الإبطال السلبي الموضوعة مباشرة بعد أول شريحة افتتاحية من كلمة regexp الخاصة بك.
|
||||||
|
|
||||||
`let numbersRegExp = /[^0-99]/ig;
|
```javacsript
|
||||||
`
|
let numbersRegExp = /[^0-99]/ig;
|
||||||
|
```
|
||||||
|
|
||||||
### تنبيه المفسد - الحل إلى الأمام
|
### تنبيه المفسد - الحل إلى الأمام
|
||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`let quoteSample = "3 blind mice.";
|
```javascript
|
||||||
let myRegex = /[^aeiou^0-99]/ig; // Change this line
|
let quoteSample = "3 blind mice.";
|
||||||
let result = quoteSample.match(myRegex); // Change this line
|
let myRegex = /[^aeiou^0-99]/ig; // Change this line
|
||||||
`
|
let result = quoteSample.match(myRegex); // Change this line
|
||||||
|
```
|
@@ -11,7 +11,8 @@ localeTitle: الإيجابية و السلبية Lookahead
|
|||||||
|
|
||||||
## حل :
|
## حل :
|
||||||
|
|
||||||
`let sampleWord = "astronaut";
|
```javascript
|
||||||
let pwRegex = /(?=\w{5,})(?=\D*\d{2})/;
|
let sampleWord = "astronaut";
|
||||||
let result = pwRegex.test(sampleWord);
|
let pwRegex = /(?=\w{5,})(?=\D*\d{2})/;
|
||||||
`
|
let result = pwRegex.test(sampleWord);
|
||||||
|
```
|
@@ -18,7 +18,8 @@ localeTitle: إزالة Whitespace من البداية والنهاية
|
|||||||
|
|
||||||
## حل:
|
## حل:
|
||||||
|
|
||||||
`let hello = " Hello, World! ";
|
```javascript
|
||||||
let wsRegex = /^\s+|\s+$/g; // Change this line
|
let hello = " Hello, World! ";
|
||||||
let result = hello.replace(wsRegex, ''); // Change this line
|
let wsRegex = /^\s+|\s+$/g; // Change this line
|
||||||
`
|
let result = hello.replace(wsRegex, ''); // Change this line
|
||||||
|
```
|
@@ -15,13 +15,15 @@ localeTitle: تقييد أسماء المستخدمين المحتملين
|
|||||||
|
|
||||||
1. الأرقام الوحيدة في اسم المستخدم يجب أن تكون في النهاية. `\d$` يمكن أن يكون هناك صفر أو أكثر منهم في النهاية. `*`
|
1. الأرقام الوحيدة في اسم المستخدم يجب أن تكون في النهاية. `\d$` يمكن أن يكون هناك صفر أو أكثر منهم في النهاية. `*`
|
||||||
|
|
||||||
`/\d*$/;
|
```javascript
|
||||||
`
|
/\d*$/;
|
||||||
|
```
|
||||||
|
|
||||||
2. يمكن أن تكون أحرف اسم المستخدم صغيرة وأحرف كبيرة. `i`
|
2. يمكن أن تكون أحرف اسم المستخدم صغيرة وأحرف كبيرة. `i`
|
||||||
|
|
||||||
`/\d*$/i;
|
```javascript
|
||||||
`
|
/\d*$/i;
|
||||||
|
```
|
||||||
|
|
||||||
3. يجب أن تتكون أسماء المستخدمين من حرفين على الأقل. `{2,}` يمكن لاسم المستخدم المكون من حرفين فقط استخدام أحرف الحروف الأبجدية. `^[az]`
|
3. يجب أن تتكون أسماء المستخدمين من حرفين على الأقل. `{2,}` يمكن لاسم المستخدم المكون من حرفين فقط استخدام أحرف الحروف الأبجدية. `^[az]`
|
||||||
|
|
||||||
|
@@ -8,10 +8,11 @@ localeTitle: إعادة استخدام الأنماط باستخدام مجمو
|
|||||||
|
|
||||||
كود المقدمة أدناه:
|
كود المقدمة أدناه:
|
||||||
|
|
||||||
`let testString = "test test test ";
|
```javascript
|
||||||
let reRegex =/(test)\s\1/;
|
let testString = "test test test ";
|
||||||
let result = reRegex.test(testString);
|
let reRegex =/(test)\s\1/;
|
||||||
`
|
let result = reRegex.test(testString);
|
||||||
|
```
|
||||||
|
|
||||||
سوف تتطابق `result` مع `test test` فقط لأن `\1` في هذا المثال تشير إلى نفس النص الذي تم مؤخرًا تطابقه مع المجموعة الأولى `(test)` .
|
سوف تتطابق `result` مع `test test` فقط لأن `\1` في هذا المثال تشير إلى نفس النص الذي تم مؤخرًا تطابقه مع المجموعة الأولى `(test)` .
|
||||||
|
|
||||||
@@ -27,10 +28,11 @@ localeTitle: إعادة استخدام الأنماط باستخدام مجمو
|
|||||||
|
|
||||||
نظرا للرمز أدناه:
|
نظرا للرمز أدناه:
|
||||||
|
|
||||||
`let testString = "test test test ";
|
```javascript
|
||||||
let reRegex =/(test)(\s)\1\2\1/;
|
let testString = "test test test ";
|
||||||
let result = reRegex.test(testString);
|
let reRegex =/(test)(\s)\1\2\1/;
|
||||||
`
|
let result = reRegex.test(testString);
|
||||||
|
```
|
||||||
|
|
||||||
سيطابق `test test test` كامل `test test test` بسبب: `\1` يكرر (اختبار) `\2` يكرر (\\ s)
|
سيطابق `test test test` كامل `test test test` بسبب: `\1` يكرر (اختبار) `\2` يكرر (\\ s)
|
||||||
|
|
||||||
@@ -38,10 +40,11 @@ localeTitle: إعادة استخدام الأنماط باستخدام مجمو
|
|||||||
|
|
||||||
الكود أدناه:
|
الكود أدناه:
|
||||||
|
|
||||||
`let testString = "test test test test test test";
|
```javascript
|
||||||
let reRegex =/(test)(\s)\1\2\1/g;
|
let testString = "test test test test test test";
|
||||||
let result = reRegex.test(testString);
|
let reRegex =/(test)(\s)\1\2\1/g;
|
||||||
`
|
let result = reRegex.test(testString);
|
||||||
|
```
|
||||||
|
|
||||||
نظرًا لأننا استخدمنا `\g` ، فلن يعود التعبير المعتاد الخاص بنا بعد أول مباراة كاملة ( `test test test` ) ويطابق كل التكرار.
|
نظرًا لأننا استخدمنا `\g` ، فلن يعود التعبير المعتاد الخاص بنا بعد أول مباراة كاملة ( `test test test` ) ويطابق كل التكرار.
|
||||||
|
|
||||||
@@ -49,7 +52,8 @@ localeTitle: إعادة استخدام الأنماط باستخدام مجمو
|
|||||||
|
|
||||||
## حل:
|
## حل:
|
||||||
|
|
||||||
`let repeatNum = "42 42 42";
|
```javascript
|
||||||
let reRegex = /^(\d+)\s\1\s\1$/;
|
let repeatNum = "42 42 42";
|
||||||
let result = reRegex.test(repeatNum);
|
let reRegex = /^(\d+)\s\1\s\1$/;
|
||||||
`
|
let result = reRegex.test(repeatNum);
|
||||||
|
```
|
||||||
|
@@ -8,15 +8,16 @@ localeTitle: تحديد العلوي والسفلي عدد من المباريا
|
|||||||
|
|
||||||
كل هذه السلاسل ستعود `true` :
|
كل هذه السلاسل ستعود `true` :
|
||||||
|
|
||||||
`let threeAs = "aaa";
|
```javascript
|
||||||
let fourAs = "aaaa";
|
let threeAs = "aaa";
|
||||||
let sevenAs = "aaaaaaa";
|
let fourAs = "aaaa";
|
||||||
|
let sevenAs = "aaaaaaa";
|
||||||
let myRegex = /a{2,4}/;
|
|
||||||
myRegex.test(threeAs) ; // true
|
let myRegex = /a{2,4}/;
|
||||||
myRegex.test(fourAs) ; // true
|
myRegex.test(threeAs) ; // true
|
||||||
myRegex.test(sevenAs) ; // true
|
myRegex.test(fourAs) ; // true
|
||||||
`
|
myRegex.test(sevenAs) ; // true
|
||||||
|
```
|
||||||
|
|
||||||
## Spolier Alert!
|
## Spolier Alert!
|
||||||
|
|
||||||
@@ -24,7 +25,8 @@ localeTitle: تحديد العلوي والسفلي عدد من المباريا
|
|||||||
|
|
||||||
## حل:
|
## حل:
|
||||||
|
|
||||||
`let ohStr = "Ohhh no";
|
```javascript
|
||||||
let ohRegex = /Oh{3,6}\sno/; // Change this line
|
let ohStr = "Ohhh no";
|
||||||
let result = ohRegex.test(ohStr);
|
let ohRegex = /Oh{3,6}\sno/; // Change this line
|
||||||
`
|
let result = ohRegex.test(ohStr);
|
||||||
|
```
|
@@ -14,8 +14,9 @@ localeTitle: استخدم مجموعات الالتقاط للبحث واستب
|
|||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`let huhText = "This sandwich is good.";
|
```javascript
|
||||||
let fixRegex = /good/; // Change this line
|
let huhText = "This sandwich is good.";
|
||||||
let replaceText = "okey-dokey"; // Change this line
|
let fixRegex = /good/; // Change this line
|
||||||
let result = huhText.replace(fixRegex, replaceText);
|
let replaceText = "okey-dokey"; // Change this line
|
||||||
`
|
let result = huhText.replace(fixRegex, replaceText);
|
||||||
|
```
|
@@ -14,7 +14,8 @@ localeTitle: باستخدام طريقة الاختبار
|
|||||||
|
|
||||||
## حل
|
## حل
|
||||||
|
|
||||||
`let myString = "Hello, World!";
|
```javascript
|
||||||
let myRegex = /Hello/;
|
let myString = "Hello, World!";
|
||||||
let result = myRegex.test(myString); // Change this line
|
let myRegex = /Hello/;
|
||||||
`
|
let result = myRegex.test(myString); // Change this line
|
||||||
|
```
|
@@ -10,7 +10,8 @@ localeTitle: تجنب مشاكل Colorblindness عن طريق اختيار ال
|
|||||||
|
|
||||||
يصبح السطر 4:
|
يصبح السطر 4:
|
||||||
|
|
||||||
`color: #003366;
|
```css
|
||||||
`
|
color: #003366;
|
||||||
|
```
|
||||||
|
|
||||||
وسوف يصبح لون النص أكثر قتامة.
|
وسوف يصبح لون النص أكثر قتامة.
|
@@ -6,10 +6,12 @@ localeTitle: جعل الروابط نافيجيتابل مع مفاتيح الو
|
|||||||
|
|
||||||
اتباع التعليمات: إضافة سمة مفتاح الوصول إلى كلا الارتباطين وتعيين أول واحد إلى "g" (لـ Garfield) والثاني إلى "c" (لـ Chuck Norris). تصبح السطور 8 و 16:
|
اتباع التعليمات: إضافة سمة مفتاح الوصول إلى كلا الارتباطين وتعيين أول واحد إلى "g" (لـ Garfield) والثاني إلى "c" (لـ Chuck Norris). تصبح السطور 8 و 16:
|
||||||
|
|
||||||
`<h2><a id="first" accesskey="g" href="">The Garfield Files: Lasagna as Training Fuel?</a></h2>
|
```css
|
||||||
`
|
<h2><a id="first" accesskey="g" href="">The Garfield Files: Lasagna as Training Fuel?</a></h2>
|
||||||
|
```
|
||||||
|
|
||||||
`<h2><a id="second" accesskey="c" href="">Is Chuck Norris a Cat Person?</a></h2>
|
```css
|
||||||
`
|
<h2><a id="second" accesskey="c" href="">Is Chuck Norris a Cat Person?</a></h2>
|
||||||
|
```
|
||||||
|
|
||||||
وبهذه الطريقة ، يمكن أن تحتوي الروابط الموجودة حول عبارتي مقالة المدونة على اختصارات لوحة المفاتيح حتى يتمكن مستخدمو موقعه من الانتقال سريعًا إلى القصة الكاملة.
|
وبهذه الطريقة ، يمكن أن تحتوي الروابط الموجودة حول عبارتي مقالة المدونة على اختصارات لوحة المفاتيح حتى يتمكن مستخدمو موقعه من الانتقال سريعًا إلى القصة الكاملة.
|
Reference in New Issue
Block a user