fix: converted single to triple backticks2 (#36229)

This commit is contained in:
Randell Dawson
2019-06-20 14:01:36 -07:00
committed by Tom
parent 5747442193
commit ac2192ce7a
75 changed files with 1403 additions and 1290 deletions

View File

@ -8,11 +8,12 @@ localeTitle: الجسيمات نعم
سنرغب في إنشاء مجموعة من الجسيمات مع التسارع والسرعات. سنقوم بإنشاء 100 جسيم في نقاط عشوائية على اللوحة. سنرغب في إنشاء مجموعة من الجسيمات مع التسارع والسرعات. سنقوم بإنشاء 100 جسيم في نقاط عشوائية على اللوحة.
`canvas = document.getElementById("canvas"); ```js
ctx = canvas.getContext('2d'); canvas = document.getElementById("canvas");
ctx = canvas.getContext('2d');
var particles = []; var particles = [];
for(var i=0; i<100; i++) { for(var i=0; i<100; i++) {
particles.push( particles.push(
{ {
x:Math.random()*canvas.width, x:Math.random()*canvas.width,
@ -23,12 +24,13 @@ localeTitle: الجسيمات نعم
ay:0 ay:0
} }
); );
} }
` ```
في حلقة الرسم لدينا ، نقدم هذه الجسيمات. في حلقة الرسم لدينا ، نقدم هذه الجسيمات.
`function draw() { ```js
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.clearRect(0, 0, canvas.width, canvas.height);
for(var i=0; i<particles.length; i++) { for(var i=0; i<particles.length; i++) {
// update state // update state
@ -40,9 +42,9 @@ localeTitle: الجسيمات نعم
} }
window.requestAnimationFrame(draw); window.requestAnimationFrame(draw);
} }
window.requestAnimationFrame(draw); window.requestAnimationFrame(draw);
` ```
الآن ، كل ما نحتاجه هو تحديث السرعة وتسريع كل إطار. سنضيف التسارع إلى السرعة وإضافة السرعة إلى الموضع. الآن ، كل ما نحتاجه هو تحديث السرعة وتسريع كل إطار. سنضيف التسارع إلى السرعة وإضافة السرعة إلى الموضع.

View File

@ -8,24 +8,26 @@ localeTitle: مسارات
يمكننا خلق مسارات استخدام مع `beginPath` ، `fill` ، و `stroke` . يمكننا خلق مسارات استخدام مع `beginPath` ، `fill` ، و `stroke` .
`ctx.beginPath(); ```js
ctx.rect(0, 0, 100, 100); ctx.beginPath();
ctx.fillStyle="black"; ctx.rect(0, 0, 100, 100);
ctx.fill(); ctx.fillStyle="black";
` ctx.fill();
```
يؤدي هذا إلى إنشاء مربع أسود في الزاوية العلوية اليمنى من اللوحة القماشية. يمكننا تغيير `strokeStyle` والتعبئات باستخدام `strokeStyle` و `fillStyle` ، `fillStyle` سلاسل ألوان تشبه CSS. يمكننا أيضا استخدام `lineWidth` لجعل السكتات الدماغية أكثر سمكا. يؤدي هذا إلى إنشاء مربع أسود في الزاوية العلوية اليمنى من اللوحة القماشية. يمكننا تغيير `strokeStyle` والتعبئات باستخدام `strokeStyle` و `fillStyle` ، `fillStyle` سلاسل ألوان تشبه CSS. يمكننا أيضا استخدام `lineWidth` لجعل السكتات الدماغية أكثر سمكا.
`ctx.beginPath(); ```js
ctx.moveTo(0,0); ctx.beginPath();
ctx.lineTo(300,150); ctx.moveTo(0,0);
ctx.moveTo(0, 100); ctx.lineTo(300,150);
ctx.lineTo(300, 250); ctx.moveTo(0, 100);
ctx.lineTo(300, 250);
ctx.strokeStyle="red"; ctx.strokeStyle="red";
ctx.lineWidth=2; ctx.lineWidth=2;
ctx.stroke(); ctx.stroke();
` ```
هناك أربع وظائف الرسم الأساسية: `rect` ، `moveTo` ، `lineTo` ، و `arc` . هناك أربع وظائف الرسم الأساسية: `rect` ، `moveTo` ، `lineTo` ، و `arc` .
@ -36,27 +38,29 @@ localeTitle: مسارات
لاحظ أن هذه الوظائف تضيف إلى مسار العمل. لا ينشئون مسارات جديدة. لاحظ أن هذه الوظائف تضيف إلى مسار العمل. لا ينشئون مسارات جديدة.
`//example 1 ```js
ctx.beginPath(); //example 1
ctx.rect(0, 0, 50, 50); ctx.beginPath();
ctx.rect(100, 100, 50, 50); ctx.rect(0, 0, 50, 50);
ctx.fill(); ctx.rect(100, 100, 50, 50);
ctx.fill();
//example 2 //example 2
ctx.beginPath(); ctx.beginPath();
ctx.rect(0, 0, 50, 50); ctx.rect(0, 0, 50, 50);
ctx.beginPath(); ctx.beginPath();
ctx.rect(100, 100, 50, 50); ctx.rect(100, 100, 50, 50);
ctx.fill(); ctx.fill();
` ```
`beginPath` المثال الأول مربعين ، بينما يرسم الثاني مربعًا واحدًا منذ أن قام `beginPath` من المستطيل الأول على مسار العمل القديم. `beginPath` المثال الأول مربعين ، بينما يرسم الثاني مربعًا واحدًا منذ أن قام `beginPath` من المستطيل الأول على مسار العمل القديم.
هذه الحقيقة تؤدي إلى خطأ شائع في صنع الرسوم المتحركة `canvas` . هذه الحقيقة تؤدي إلى خطأ شائع في صنع الرسوم المتحركة `canvas` .
`var x = 0; ```js
var y = 0; var x = 0;
function draw() { var y = 0;
function draw() {
ctx.clearRect(0, 0, canvas.width, canvas.height); ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.rect(x, y, 50, 50); ctx.rect(x, y, 50, 50);
@ -64,10 +68,10 @@ localeTitle: مسارات
x+=1; x+=1;
window.requestAnimationFrame(draw); window.requestAnimationFrame(draw);
} }
window.requestAnimationFrame(draw); window.requestAnimationFrame(draw);
` ```
الرسم المتحرك أعلاه ، الذي من المفترض أن يقوم بتحريك مربع عبر الشاشة ، ينشئ شريط أسود طويل بدلاً من ذلك. السبب هو أن `beginPath` لا يسمى داخل حلقة `draw` . الرسم المتحرك أعلاه ، الذي من المفترض أن يقوم بتحريك مربع عبر الشاشة ، ينشئ شريط أسود طويل بدلاً من ذلك. السبب هو أن `beginPath` لا يسمى داخل حلقة `draw` .

View File

@ -8,13 +8,14 @@ localeTitle: سلسلة Middleware لإنشاء خادم الوقت
بدلاً من الاستجابة مع الوقت ، يمكننا أيضًا إضافة سلسلة إلى الطلب وتمريرها إلى الوظيفة التالية. هذا تافه ، لكنه يجعل مثالًا جيدًا. يبدو الرمز مثل: بدلاً من الاستجابة مع الوقت ، يمكننا أيضًا إضافة سلسلة إلى الطلب وتمريرها إلى الوظيفة التالية. هذا تافه ، لكنه يجعل مثالًا جيدًا. يبدو الرمز مثل:
`app.get("/now", middleware(req, res, next) { ```javascript
app.get("/now", middleware(req, res, next) {
req.string = "example"; req.string = "example";
next(); next();
}, },
function (req, res) { function (req, res) {
res.send(req.string); // This will display "example" to the user res.send(req.string); // This will display "example" to the user
}); });
` ```
[ساعد مجتمعنا على توسيع هذه التلميحات والأدلة](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/apis-and-microservices/basic-node-and-express/chain-middleware-to-create-a-time-server/index.md) . [ساعد مجتمعنا على توسيع هذه التلميحات والأدلة](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/apis-and-microservices/basic-node-and-express/chain-middleware-to-create-a-time-server/index.md) .

View File

@ -8,9 +8,10 @@ localeTitle: الحصول على البيانات من طلبات POST
للحصول على بيانات من طلب النشر ، يكون التنسيق العام هو: للحصول على بيانات من طلب النشر ، يكون التنسيق العام هو:
`app.post(PATH, function(req, res) { ```javascript
app.post(PATH, function(req, res) {
// Handle the data in the request // Handle the data in the request
}); });
` ```
[ساعد مجتمعنا على توسيع هذه التلميحات والأدلة](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/apis-and-microservices/basic-node-and-express/use-body-parser-to-parse-post-requests/index.md) . [ساعد مجتمعنا على توسيع هذه التلميحات والأدلة](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/apis-and-microservices/basic-node-and-express/use-body-parser-to-parse-post-requests/index.md) .

View File

@ -6,10 +6,11 @@ localeTitle: الحصول على إدخال معلمة المسار من الع
إذا طلب منك أحد الأشخاص إنشاء GET أو POST ، فستفعل app.get (…) أو app.post (…) وفقًا لذلك. الهيكل الأساسي للتحدي هو: إذا طلب منك أحد الأشخاص إنشاء GET أو POST ، فستفعل app.get (…) أو app.post (…) وفقًا لذلك. الهيكل الأساسي للتحدي هو:
`app.get("/:word/echo", function(req, res) { ```javascript
app.get("/:word/echo", function(req, res) {
// word = req.params.word; // word = req.params.word;
// respond with the json object // respond with the json object
}); });
` ```
[ساعد مجتمعنا على توسيع هذه التلميحات والأدلة](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/apis-and-microservices/basic-node-and-express/get-route-parameter-input-from-the-client/index.md) . [ساعد مجتمعنا على توسيع هذه التلميحات والأدلة](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/apis-and-microservices/basic-node-and-express/get-route-parameter-input-from-the-client/index.md) .

View File

@ -8,12 +8,13 @@ localeTitle: تنفيذ برنامج طلب تسجيل مستوى الجذر ا
لإعداد البرنامج الوسيط الخاص بك ، يمكنك القيام بذلك كما يلي: لإعداد البرنامج الوسيط الخاص بك ، يمكنك القيام بذلك كما يلي:
`app.use(function middleware(req, res, next) { ```javascript
app.use(function middleware(req, res, next) {
// Do something // Do something
// Call the next function in line: // Call the next function in line:
next(); next();
}); });
` ```
إذا واجهتك مشكلة في تنسيق السلسلة بشكل صحيح ، فستبدو طريقة واحدة لتنفيذها كما يلي: إذا واجهتك مشكلة في تنسيق السلسلة بشكل صحيح ، فستبدو طريقة واحدة لتنفيذها كما يلي:

View File

@ -6,16 +6,18 @@ localeTitle: بدء تشغيل خادم اكسبرس العمل
إذا كان لديك موقع ويب على "example.com/" وأردت تقديم سلسلة مثل "Hello World" لمن يزور النطاق الجذر ، فيمكنك إجراء ذلك بسهولة باستخدام العقدة و / أو التعبير السريع: إذا كان لديك موقع ويب على "example.com/" وأردت تقديم سلسلة مثل "Hello World" لمن يزور النطاق الجذر ، فيمكنك إجراء ذلك بسهولة باستخدام العقدة و / أو التعبير السريع:
`app.get("/", function(req, res) { ```javascript
app.get("/", function(req, res) {
res.send("Hello World"); res.send("Hello World");
}); });
` ```
أيضًا ، باستخدام ES6 + يمكنك حفظ بعض الكتابة باستخدام "=>" بدلاً من "الوظيفة" ، والتي تبدو كالتالي: أيضًا ، باستخدام ES6 + يمكنك حفظ بعض الكتابة باستخدام "=>" بدلاً من "الوظيفة" ، والتي تبدو كالتالي:
`app.get("/", (req, res) => { ```javascript
app.get("/", (req, res) => {
res.send("Hello World"); res.send("Hello World");
}); });
` ```
[ساعد مجتمعنا على توسيع هذه التلميحات والأدلة](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/apis-and-microservices/basic-node-and-express/start-a-working-express-server/index.md) . [ساعد مجتمعنا على توسيع هذه التلميحات والأدلة](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/apis-and-microservices/basic-node-and-express/start-a-working-express-server/index.md) .

View File

@ -6,10 +6,11 @@ localeTitle: استخدام محلل الجسم إلى Parse POST الطلبات
يجب إضافة محلل الجسد بالفعل إلى مشروعك إذا كنت تستخدم النص المتوفر ، ولكن إذا لم يكن كذلك ، فيجب أن يكون موجودًا على النحو التالي: يجب إضافة محلل الجسد بالفعل إلى مشروعك إذا كنت تستخدم النص المتوفر ، ولكن إذا لم يكن كذلك ، فيجب أن يكون موجودًا على النحو التالي:
`"dependencies": { ```code
"dependencies": {
"body-parser": "^1.4.3", "body-parser": "^1.4.3",
... ...
` ```
ما عليك القيام به لهذا التحدي هو تمرير الوسيطة إلى app.use (). تأكد من أنها تأتي قبل المسارات التي تحتاج إلى استخدامها. ما عليك القيام به لهذا التحدي هو تمرير الوسيطة إلى app.use (). تأكد من أنها تأتي قبل المسارات التي تحتاج إلى استخدامها.

View File

@ -6,13 +6,15 @@ localeTitle: سلسلة بحث مساعدة المساعدين لضيق نتائ
1. لإنشاء ولكن لا يتم تنفيذ استعلام بحث 1. لإنشاء ولكن لا يتم تنفيذ استعلام بحث
`Model.find( {name: 'Leah'} ) ```javascript
` Model.find( {name: 'Leah'} )
```
2. لتخزين استعلام البحث في متغير لاستخدامه لاحقًا: 2. لتخزين استعلام البحث في متغير لاستخدامه لاحقًا:
`var findQuery = YourModel.find( {name: 'Leah'} ) ```javascript
` var findQuery = YourModel.find( {name: 'Leah'} )
```
3. لفرز مصفوفة: 3. لفرز مصفوفة:
@ -21,35 +23,40 @@ localeTitle: سلسلة بحث مساعدة المساعدين لضيق نتائ
4. لتحديد حجم المصفوفة: 4. لتحديد حجم المصفوفة:
`yourArray.limit(5) // return array which has 5 items in it. ```javascript
` yourArray.limit(5) // return array which has 5 items in it.
```
5. لإخفاء خاصية معينة من النتيجة: 5. لإخفاء خاصية معينة من النتيجة:
`yourArray.select( {name: 0, age: 1} ) // Here: 0 means false and thus hide name property; 1 means true so age property will show. ```javascript
` yourArray.select( {name: 0, age: 1} ) // Here: 0 means false and thus hide name property; 1 means true so age property will show.
```
6. لتنفيذ هذا الاستعلام ، يمكنك إما: 6. لتنفيذ هذا الاستعلام ، يمكنك إما:
1) رد الاتصال: 1) رد الاتصال:
`YourQuery.exec(function(err, docs) { ```javascript
YourQuery.exec(function(err, docs) {
//do something here //do something here
}) })
` ```
أو 2) وعد أو 2) وعد
`YourQuery.exec.then(function(err, docs) { ```javascript
YourQuery.exec.then(function(err, docs) {
//do something here //do something here
}) })
` ```
7. سلسلة كل ذلك معا: 7. سلسلة كل ذلك معا:
`Person.find({age: 55}).sort({name: -1}).limit(5).select( {favoriteFoods: 0} ).exec(function(error, people) { ```javascript
Person.find({age: 55}).sort({name: -1}).limit(5).select( {favoriteFoods: 0} ).exec(function(error, people) {
//do something here //do something here
}) })
` ```

View File

@ -16,12 +16,13 @@ localeTitle: تنفيذ فرز الفقاعة
#### الحل 1: الأساسي #### الحل 1: الأساسي
`function swap(a, b, arr){ ```js
function swap(a, b, arr){
let tmp = arr[a]; let tmp = arr[a];
arr[a] = arr[b]; arr[a] = arr[b];
arr[b] = tmp; arr[b] = tmp;
} }
function bubbleSort(array) { function bubbleSort(array) {
for (let i = 0; i < array.length; i++){ for (let i = 0; i < array.length; i++){
for (let j = 0; j < array.length-1-i; j++){ // -i because the largest element will be bubbled at the end so we don't have to compare. for (let j = 0; j < array.length-1-i; j++){ // -i because the largest element will be bubbled at the end so we don't have to compare.
if (array[j] > array[j+1]){ if (array[j] > array[j+1]){
@ -30,8 +31,8 @@ localeTitle: تنفيذ فرز الفقاعة
} }
} }
return array; return array;
} }
` ```
#### الحل 2: متقدم #### الحل 2: متقدم

View File

@ -19,7 +19,8 @@ localeTitle: تنفيذ فرز الإدراج
### حل: ### حل:
`function insertionSort(array) { ```js
function insertionSort(array) {
for (let i = 1; i < array.length; i++){ for (let i = 1; i < array.length; i++){
let curr = array[i]; let curr = array[i];
for (var j = i-1; j >= 0 && array[j] > curr; j--){ for (var j = i-1; j >= 0 && array[j] > curr; j--){
@ -28,8 +29,8 @@ localeTitle: تنفيذ فرز الإدراج
array[j+1] = curr; array[j+1] = curr;
} }
return array; return array;
} }
` ```
### المراجع: ### المراجع:

View File

@ -18,12 +18,13 @@ localeTitle: تنفيذ فرز التحديد
### حل: ### حل:
`function swap(a, b, arr){ ```js
function swap(a, b, arr){
let tmp = arr[a]; let tmp = arr[a];
arr[a] = arr[b]; arr[a] = arr[b];
arr[b] = tmp; arr[b] = tmp;
} }
function selectionSort(array) { function selectionSort(array) {
for (let i = 0; i < array.length-1; i++){ for (let i = 0; i < array.length-1; i++){
let min = i; let min = i;
for (let j = i+1; j < array.length; j++){ for (let j = i+1; j < array.length; j++){
@ -32,8 +33,8 @@ localeTitle: تنفيذ فرز التحديد
swap(i, min, array); swap(i, min, array);
} }
return array; return array;
} }
` ```
### المراجع: ### المراجع:

View File

@ -6,12 +6,13 @@ localeTitle: اتساع البحث الأول
دعونا أولا تحديد فئة `Tree` لاستخدامها لتنفيذ خوارزمية Breadth First Search. دعونا أولا تحديد فئة `Tree` لاستخدامها لتنفيذ خوارزمية Breadth First Search.
`class Tree: ```python
class Tree:
def __init__(self, x): def __init__(self, x):
self.val = x self.val = x
self.left = None self.left = None
self.right = None self.right = None
` ```
تنتقل خوارزمية البحث الأولى والاتساع من مستوى إلى آخر بدءًا من جذر الشجرة. سنستخدم `queue` لهذا الغرض. تنتقل خوارزمية البحث الأولى والاتساع من مستوى إلى آخر بدءًا من جذر الشجرة. سنستخدم `queue` لهذا الغرض.

View File

@ -24,7 +24,8 @@ localeTitle: إنشاء فئة مكدس
#### الأساسية: #### الأساسية:
`function Stack() { ```js
function Stack() {
var collection = []; var collection = [];
this.print = function() { this.print = function() {
console.log(collection); console.log(collection);
@ -44,12 +45,13 @@ localeTitle: إنشاء فئة مكدس
this.clear = function(){ this.clear = function(){
collection.length = 0; collection.length = 0;
} }
} }
` ```
#### متقدم - بنية ES6 Class: #### متقدم - بنية ES6 Class:
`class Stack { ```js
class Stack {
constructor() { constructor() {
this.collection = []; this.collection = [];
} }
@ -71,8 +73,8 @@ localeTitle: إنشاء فئة مكدس
clear(){ clear(){
return this.collection.length = 0; return this.collection.length = 0;
} }
} }
` ```
\### مصادر: \### مصادر:

View File

@ -19,32 +19,37 @@ localeTitle: ابحث عن الحد الأدنى والحد الأقصى لار
### لوحة المفاتيح ### لوحة المفاتيح
`Ctrl + Shift + I ```
` Ctrl + Shift + I
```
### شريط القوائم ### شريط القوائم
#### ثعلب النار #### ثعلب النار
`Tools ➤ Web Developer ➤ Toggle Tools ```
` Tools ➤ Web Developer ➤ Toggle Tools
```
#### كروم / الكروم #### كروم / الكروم
`Tools ➤ Developer Tools ```
` Tools ➤ Developer Tools
```
#### رحلات السفاري #### رحلات السفاري
`Develop ➤ Show Web Inspector. ```
` Develop ➤ Show Web Inspector.
```
إذا لم تتمكن من رؤية قائمة التطوير ، فانتقل إلى `Safari ➤ Preferences ➤ Advanced` وتحقق من مربع الاختيار `Show Develop menu` في شريط القائمة. إذا لم تتمكن من رؤية قائمة التطوير ، فانتقل إلى `Safari ➤ Preferences ➤ Advanced` وتحقق من مربع الاختيار `Show Develop menu` في شريط القائمة.
#### دار الأوبرا #### دار الأوبرا
`Developer ➤ Web Inspector ```
` Developer ➤ Web Inspector
```
### قائمة السياق ### قائمة السياق

View File

@ -14,11 +14,12 @@ localeTitle: تعرف على كيفية عمل Stack
### حل: ### حل:
`var homeworkStack = ["BIO12","HIS80","MAT122","PSY44"]; ```js
var homeworkStack = ["BIO12","HIS80","MAT122","PSY44"];
homeworkStack.pop(); homeworkStack.pop();
homeworkStack.push("CS50"); homeworkStack.push("CS50");
` ```
### مرجع: ### مرجع:

View File

@ -11,12 +11,13 @@ localeTitle: مصفوفات مكتوبة
### حل: ### حل:
`//Create a buffer of 64 bytes ```js
var buffer = new ArrayBuffer(64); //Create a buffer of 64 bytes
var buffer = new ArrayBuffer(64);
//Make 32-bit int typed array with the above buffer //Make 32-bit int typed array with the above buffer
var i32View = new Int32Array(buffer); var i32View = new Int32Array(buffer);
` ```
### المراجع: ### المراجع:

View File

@ -13,15 +13,16 @@ localeTitle: مضاعفات 3 و 5
### حل: ### حل:
`function multiplesOf3and5(number) { ```js
function multiplesOf3and5(number) {
let sum = 0, i = 3; let sum = 0, i = 3;
while (i < number){ while (i < number){
if (i % 3 == 0 || i % 5 == 0) sum += i; if (i % 3 == 0 || i % 5 == 0) sum += i;
i++; i++;
} }
return sum; return sum;
} }
` ```
### مرجع: ### مرجع:

View File

@ -21,7 +21,8 @@ localeTitle: حتى أرقام فيبوناتشي
#### الحل الأساسي - تكراري: #### الحل الأساسي - تكراري:
`function fiboEvenSum(n) { ```js
function fiboEvenSum(n) {
let first = 1, second = 2, sum = 2, fibNum; // declaring and initializing variables let first = 1, second = 2, sum = 2, fibNum; // declaring and initializing variables
if (n <= 1) return sum; // edge case if (n <= 1) return sum; // edge case
for (let i = 2; i <= n; i++){ // looping till n for (let i = 2; i <= n; i++){ // looping till n
@ -31,13 +32,14 @@ localeTitle: حتى أرقام فيبوناتشي
if (fibNum%2 == 0) sum+=fibNum; // If even add to the sum variable if (fibNum%2 == 0) sum+=fibNum; // If even add to the sum variable
} }
return sum; return sum;
} }
` ```
#### حل متقدم - متكرر: #### حل متقدم - متكرر:
`// We use memoization technique to save ith fibonacci number to the fib array ```js
function fiboEvenSum(n){ // We use memoization technique to save ith fibonacci number to the fib array
function fiboEvenSum(n){
const fib = [1, 2]; const fib = [1, 2];
let sumEven = fib[1]; let sumEven = fib[1];
function fibonacci(n){ function fibonacci(n){
@ -51,8 +53,8 @@ localeTitle: حتى أرقام فيبوناتشي
} }
fibonacci(n); // run the recursive function fibonacci(n); // run the recursive function
return sumEven; return sumEven;
} }
` ```
### المراجع: ### المراجع:

View File

@ -12,7 +12,8 @@ localeTitle: أكبر عامل رئيسي
### حل: ### حل:
`function largestPrimeFactor(number) { ```js
function largestPrimeFactor(number) {
let prime = 2, max = 1; let prime = 2, max = 1;
while (prime <= number){ while (prime <= number){
if (number % prime == 0) { if (number % prime == 0) {
@ -22,8 +23,8 @@ localeTitle: أكبر عامل رئيسي
else prime++; //Only increment the prime number if the number isn't divisible by it else prime++; //Only increment the prime number if the number isn't divisible by it
} }
return max; return max;
} }
` ```
### مصادر: ### مصادر:

View File

@ -28,22 +28,24 @@ else {
} }
`What you need to remember is the bracket that the if-else logic associate with, (argument) and {statement} ```
What you need to remember is the bracket that the if-else logic associate with, (argument) and {statement}
**Try Yourself Now** 👩‍💻👨‍💻 **Try Yourself Now** 👩‍💻👨‍💻
**Ternary operator** **Ternary operator**
A more detailed explanation [here](https://codeburst.io/javascript-the-conditional-ternary-operator-explained-cac7218beeff). Ternary operator is a lot more concise and quicker to remember for a simple true or false statement. Read [this](https://www.thoughtco.com/javascript-by-example-use-of-the-ternary-operator-2037394) A more detailed explanation [here](https://codeburst.io/javascript-the-conditional-ternary-operator-explained-cac7218beeff). Ternary operator is a lot more concise and quicker to remember for a simple true or false statement. Read [this](https://www.thoughtco.com/javascript-by-example-use-of-the-ternary-operator-2037394)
` ```
جافا سكريبت جافا سكريبت
شرط ؟ القيمة إذا كانت صحيحة: value if false شرط ؟ القيمة إذا كانت صحيحة: value if false
`For someone who still not sure here is a solution by using If-else statement ```
` For someone who still not sure here is a solution by using If-else statement
```
جافا سكريبت .style ("color"، (d) => { إذا ((د <20) { العودة "الحمراء" } else { العودة "الخضراء" } }) \`\` \` جافا سكريبت .style ("color"، (d) => { إذا ((د <20) { العودة "الحمراء" } else { العودة "الخضراء" } }) \`\` \`

View File

@ -10,15 +10,15 @@ localeTitle: إضافة عناصر داخل الآبار Bootstrap الخاص ب
يتم الإعلان عن زر على النحو التالي: يتم الإعلان عن زر على النحو التالي:
` ```html
<button></button> <button></button>
` ```
### حل ### حل
نظرًا لأنه يتعين علينا إعلان 3 زر في كل بئر ، سنفعل ما يلي: نظرًا لأنه يتعين علينا إعلان 3 زر في كل بئر ، سنفعل ما يلي:
` ```html
<div class="container-fluid"> <div class="container-fluid">
<h3 class="text-primary text-center">jQuery Playground</h3> <h3 class="text-primary text-center">jQuery Playground</h3>
<div class="row"> <div class="row">
@ -37,5 +37,5 @@ localeTitle: إضافة عناصر داخل الآبار Bootstrap الخاص ب
</div> </div>
</div> </div>
</div> </div>
</div> </div>
` ```

View File

@ -25,9 +25,9 @@ localeTitle: إضافة أيقونات روعة للخط إلى جميع أزر
### حل: ### حل:
` ```html
<link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Lobster" rel="stylesheet" type="text/css">
<style> <style>
h2 { h2 {
font-family: Lobster, Monospace; font-family: Lobster, Monospace;
} }
@ -38,9 +38,9 @@ localeTitle: إضافة أيقونات روعة للخط إلى جميع أزر
border-style: solid; border-style: solid;
border-radius: 50%; border-radius: 50%;
} }
</style> </style>
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> <div class="row">
<div class="col-xs-8"> <div class="col-xs-8">
<h2 class="text-primary text-center">CatPhotoApp</h2> <h2 class="text-primary text-center">CatPhotoApp</h2>
@ -82,5 +82,5 @@ localeTitle: إضافة أيقونات روعة للخط إلى جميع أزر
<input type="text" placeholder="cat photo URL" required> <input type="text" placeholder="cat photo URL" required>
<button type="submit">Submit</button> <button type="submit">Submit</button>
</form> </form>
</div> </div>
` ```

View File

@ -10,9 +10,9 @@ localeTitle: أضف سمات المعرف إلى عناصر Bootstrap
يتم تعريف معرف على النحو التالي: يتم تعريف معرف على النحو التالي:
` ```html
<element id="id(s)List"></element> <element id="id(s)List"></element>
` ```
### تلميح 2 ### تلميح 2
@ -30,7 +30,7 @@ localeTitle: أضف سمات المعرف إلى عناصر Bootstrap
نظرًا لأنك تحتاج إلى إضافة معرّف (معرّفات) إلى كلٍّ من الآبار ولديك كلاً من معرف فريد ، فإن ما يلي هو الحل: نظرًا لأنك تحتاج إلى إضافة معرّف (معرّفات) إلى كلٍّ من الآبار ولديك كلاً من معرف فريد ، فإن ما يلي هو الحل:
` ```html
<div class="container-fluid"> <div class="container-fluid">
<h3 class="text-primary text-center">jQuery Playground</h3> <h3 class="text-primary text-center">jQuery Playground</h3>
<div class="row"> <div class="row">
@ -49,5 +49,5 @@ localeTitle: أضف سمات المعرف إلى عناصر Bootstrap
</div> </div>
</div> </div>
</div> </div>
</div> </div>
` ```

View File

@ -10,15 +10,15 @@ localeTitle: قم بتطبيق نمط زر Bootstrap الافتراضي
يتم تعريف الفئة باستخدام بناء الجملة التالي: يتم تعريف الفئة باستخدام بناء الجملة التالي:
` ```html
<button class="class(es)Name"></button> <button class="class(es)Name"></button>
` ```
### حل ### حل
نظرًا لأنك `btn` إلى إضافة فئات `btn` و `btn-default` ، فإن ما يلي هو الحل: نظرًا لأنك `btn` إلى إضافة فئات `btn` و `btn-default` ، فإن ما يلي هو الحل:
` ```html
<div class="container-fluid"> <div class="container-fluid">
<h3 class="text-primary text-center">jQuery Playground</h3> <h3 class="text-primary text-center">jQuery Playground</h3>
<div class="row"> <div class="row">
@ -37,5 +37,5 @@ localeTitle: قم بتطبيق نمط زر Bootstrap الافتراضي
</div> </div>
</div> </div>
</div> </div>
</div> </div>
` ```

View File

@ -14,7 +14,7 @@ localeTitle: إنشاء فئة إلى الهدف باستخدام محددات j
نظرًا لأنك مضطر لإضافة فئة `target` ، فإن ما يلي هو الحل: نظرًا لأنك مضطر لإضافة فئة `target` ، فإن ما يلي هو الحل:
` ```html
<div class="container-fluid"> <div class="container-fluid">
<h3 class="text-primary text-center">jQuery Playground</h3> <h3 class="text-primary text-center">jQuery Playground</h3>
<div class="row"> <div class="row">
@ -33,5 +33,5 @@ localeTitle: إنشاء فئة إلى الهدف باستخدام محددات j
</div> </div>
</div> </div>
</div> </div>
</div> </div>
` ```

View File

@ -8,8 +8,9 @@ localeTitle: التمهيد
مقتبس من موقع Bootstrap: مقتبس من موقع Bootstrap:
`Bootstrap is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with our Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful plugins built on jQuery. ```
` Bootstrap is an open source toolkit for developing with HTML, CSS, and JS. Quickly prototype your ideas or build your entire app with our Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful plugins built on jQuery.
```
يجد إطار العمل قابلية للتوظيف في العديد من مشاريع الواجهة الأمامية ويعتبر نوي هو أشهر إطار عمل HTML و CSS. يجد إطار العمل قابلية للتوظيف في العديد من مشاريع الواجهة الأمامية ويعتبر نوي هو أشهر إطار عمل HTML و CSS.

View File

@ -9,10 +9,11 @@ localeTitle: عناصر الهدف حسب الفئة باستخدام jQuery
## حل ## حل
`<script> ```javascript
<script>
$(document).ready(function() { $(document).ready(function() {
$(".well").addClass("animated bounce"); $(".well").addClass("animated bounce");
$(".well").addClass("shake"); $(".well").addClass("shake");
}); });
</script> </script>
` ```

View File

@ -6,11 +6,12 @@ localeTitle: عناصر الهدف عن طريق id استخدام jQuery
## حل ## حل
`<script> ```javascript
<script>
$(document).ready(function() { $(document).ready(function() {
$("button").addClass("animated bounce"); $("button").addClass("animated bounce");
$(".well").addClass("animated shake"); $(".well").addClass("animated shake");
$("#target3").addClass("fadeOut"); // Target elements with the id "target3" and add the class "fadeOut" to them. $("#target3").addClass("fadeOut"); // Target elements with the id "target3" and add the class "fadeOut" to them.
}); });
</script> </script>
` ```

View File

@ -8,19 +8,21 @@ localeTitle: عناصر HTML الهدف مع المحددات باستخدام j
## مثال ## مثال
`//You can select all <p> elements on a page like this = $("p") ```javascipt
//You can select all <p> elements on a page like this = $("p")
$(document).ready(function(){ $(document).ready(function(){
$("button").click(function(){ $("button").click(function(){
$("p").hide(); $("p").hide();
}); });
}); });
` ```
## حل ## حل
`<script> ```javascript
<script>
$(document).ready(function() { $(document).ready(function() {
$("button").addClass("animated bounce"); // We are selecting the button elements and adding "animated bounce" class to them. $("button").addClass("animated bounce"); // We are selecting the button elements and adding "animated bounce" class to them.
}); });
</script> </script>
` ```

View File

@ -6,9 +6,10 @@ localeTitle: استهداف أصل عنصر باستخدام jQuery
## حل ## حل
`<script> ```js
<script>
$(document).ready(function() { $(document).ready(function() {
$("#target1").parent().css("background-color", "red"); // Selects the parent of #target1 and changes its background-color to red $("#target1").parent().css("background-color", "red"); // Selects the parent of #target1 and changes its background-color to red
}); });
</script> </script>
` ```

View File

@ -6,11 +6,12 @@ localeTitle: استهدف عنصر نفسه باستخدام محددات jQuery
## حل ## حل
`<script> ```javascript
<script>
$(document).ready(function() { $(document).ready(function() {
$("button").addClass("animated"); // Target elements with type "button" and add the class "animated" to them. $("button").addClass("animated"); // Target elements with type "button" and add the class "animated" to them.
$(".btn").addClass("shake"); // Target elements with class ".btn" and add the class "shake" to them. $(".btn").addClass("shake"); // Target elements with class ".btn" and add the class "shake" to them.
$("#target1").addClass("btn-primary"); // Target elements with id "#target1" and add the class "btn-primary" to them. $("#target1").addClass("btn-primary"); // Target elements with id "#target1" and add the class "btn-primary" to them.
}); });
</script> </script>
` ```

View File

@ -14,8 +14,9 @@ localeTitle: استخدم jQuery لتعديل الصفحة بأكملها
### حل: ### حل:
`<script> ```javascript
<script>
$("body").addClass("animated hinge"); $("body").addClass("animated hinge");
}); });
</script> </script>
` ```

View File

@ -10,20 +10,21 @@ localeTitle: استخراج الدولة المنطق إلى Redux
الحل المقترح: الحل المقترح:
`const ADD = 'ADD'; ```javascript
const ADD = 'ADD';
function addMessage(message) { function addMessage(message) {
return { return {
type: ADD, type: ADD,
message: message message: message
}; };
}; };
function messageReducer (previousState, action) { function messageReducer (previousState, action) {
return [...previousState, action.message]; return [...previousState, action.message];
} }
let store = { let store = {
state: [], state: [],
getState: () => store.state, getState: () => store.state,
dispatch: (action) => { dispatch: (action) => {
@ -31,5 +32,5 @@ localeTitle: استخراج الدولة المنطق إلى Redux
store.state = messageReducer(store.state, action); store.state = messageReducer(store.state, action);
} }
} }
}; };
` ```

View File

@ -8,8 +8,9 @@ localeTitle: أضف تعليقات في JSX
* تعليق سطر واحد: * تعليق سطر واحد:
`{/*<h1>Hanoi University of Science</h1>*/} ```jsx
` {/*<h1>Hanoi University of Science</h1>*/}
```
* تعليقات متعددة الخطوط: * تعليقات متعددة الخطوط:
@ -21,6 +22,6 @@ localeTitle: أضف تعليقات في JSX
ملاحظة: لا يمكنك استخدام تعليق HTML في JSX على النحو التالي: ملاحظة: لا يمكنك استخدام تعليق HTML في JSX على النحو التالي:
` ```html
<!-- not working --> <!-- not working -->
` ```

View File

@ -10,7 +10,8 @@ localeTitle: اضافة المستمعين الحدث
ملاحظة: document.addEventListener و document.removeEventListener سوف يأخذ في سلسلة مقتبسة عن الحدث الخاص به ، وعند تمريره في الدالة ، ستشير إليه handleKeyPress () باسم this.handleKeyPress. إذا قمت باستدعاء الدالة على هذا .handleKeyPress () ، سيقوم مستمع الحدث بتقييم الدالة أولاً وسيعيد قيمة غير معرفة. ملاحظة: document.addEventListener و document.removeEventListener سوف يأخذ في سلسلة مقتبسة عن الحدث الخاص به ، وعند تمريره في الدالة ، ستشير إليه handleKeyPress () باسم this.handleKeyPress. إذا قمت باستدعاء الدالة على هذا .handleKeyPress () ، سيقوم مستمع الحدث بتقييم الدالة أولاً وسيعيد قيمة غير معرفة.
`class MyComponent extends React.Component { ```javascript
class MyComponent extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -44,8 +45,8 @@ localeTitle: اضافة المستمعين الحدث
</div> </div>
); );
} }
}; };
` ```
### مصادر ### مصادر

View File

@ -8,7 +8,8 @@ localeTitle: إضافة أنماط مضمنة في React
### المفسد ### المفسد
`class Colorful extends React.Component { ```jsx
class Colorful extends React.Component {
render() { render() {
// change code below this line // change code below this line
return ( return (
@ -16,8 +17,8 @@ localeTitle: إضافة أنماط مضمنة في React
); );
// change code above this line // change code above this line
} }
}; };
` ```
### مصادر ### مصادر

View File

@ -23,7 +23,8 @@ localeTitle: ربط "هذا" لطريقة Class
## المفسد ## المفسد
`class MyComponent extends React.Component { ```jsx
class MyComponent extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -48,5 +49,5 @@ localeTitle: ربط "هذا" لطريقة Class
</div> </div>
); );
} }
} }
` ```

View File

@ -8,8 +8,9 @@ localeTitle: تغيير CSS المضمنة بناء على حالة المكون
ستقوم بالتحقق من طول هذا `this.state.input` بحيث تستخدم خاصية `.length` . ستقوم بالتحقق من طول هذا `this.state.input` بحيث تستخدم خاصية `.length` .
`this.state.input.length ```
` this.state.input.length
```
## تلميح 2: ## تلميح 2:
@ -19,7 +20,8 @@ localeTitle: تغيير CSS المضمنة بناء على حالة المكون
ستستخدم عبارة `if/then` للتحقق من قيمة هذا `this.state.input.length` . إذا كان أطول من 15 ، `inputStyle.border` `'3px solid red'` إلى `inputStyle.border` . ستستخدم عبارة `if/then` للتحقق من قيمة هذا `this.state.input.length` . إذا كان أطول من 15 ، `inputStyle.border` `'3px solid red'` إلى `inputStyle.border` .
`class GateKeeper extends React.Component { ```jsx
class GateKeeper extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -50,8 +52,8 @@ localeTitle: تغيير CSS المضمنة بناء على حالة المكون
</div> </div>
); );
} }
}; };
` ```
## حل ## حل

View File

@ -12,7 +12,8 @@ localeTitle: تأليف React Components
ما يلي هو الحل لل chakkenge ، حيث تجعل الحمضيات و NonCitrus في مكون ثم يتم تقديمها في آخر: ما يلي هو الحل لل chakkenge ، حيث تجعل الحمضيات و NonCitrus في مكون ثم يتم تقديمها في آخر:
`class Fruits extends React.Component { ```jsx
class Fruits extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
} }
@ -25,9 +26,9 @@ localeTitle: تأليف React Components
</div> </div>
); );
} }
}; };
class TypesOfFood extends React.Component { class TypesOfFood extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
} }
@ -39,8 +40,8 @@ localeTitle: تأليف React Components
</div> </div>
); );
} }
}; };
` ```
### روابط ذات صلة: ### روابط ذات صلة:

View File

@ -20,7 +20,8 @@ localeTitle: إنشاء مكون مع التركيب
سوف يقدم التالية في ChildComponent في ParentComponent ، كما هو مطلوب: سوف يقدم التالية في ChildComponent في ParentComponent ، كما هو مطلوب:
`class ParentComponent extends React.Component { ```javascript
class ParentComponent extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
} }
@ -32,5 +33,5 @@ localeTitle: إنشاء مكون مع التركيب
</div> </div>
); );
} }
}; };
` ```

View File

@ -26,5 +26,6 @@ localeTitle: إنشاء نموذج التحكم
والآن بعد أن يتم التعامل مع بياناتك في الحالة ، يمكننا استخدام هذه البيانات. قم بإنشاء عنصر `h1` . داخل عنصر `h1` ضع متغير "إرسال" الخاص بك. تذكر أن "submit" يقع داخل الولاية لذا ستحتاج إلى استخدام هذا `this.state` . بالإضافة إلى ذلك ، يتطلب وضع المتغير داخل JSX أقواسًا متعرجة `{ }` لأنها جافا سكريبت. والآن بعد أن يتم التعامل مع بياناتك في الحالة ، يمكننا استخدام هذه البيانات. قم بإنشاء عنصر `h1` . داخل عنصر `h1` ضع متغير "إرسال" الخاص بك. تذكر أن "submit" يقع داخل الولاية لذا ستحتاج إلى استخدام هذا `this.state` . بالإضافة إلى ذلك ، يتطلب وضع المتغير داخل JSX أقواسًا متعرجة `{ }` لأنها جافا سكريبت.
`<h1>{this.state.submit}</h1> ```jsx
` <h1>{this.state.submit}</h1>
```

View File

@ -10,26 +10,30 @@ localeTitle: إنشاء مدخلات متحكم بها
لذلك أنت الخطوة الأولى سوف يجعل وظيفة يقوم بتغيير المتغير الدولة `input` . لذلك أنت الخطوة الأولى سوف يجعل وظيفة يقوم بتغيير المتغير الدولة `input` .
`handleChange(event) { ```
handleChange(event) {
this.setState({ this.setState({
input: event.target.value input: event.target.value
}); });
} }
` ```
ستشمل خطوتك التالية إنشاء مربع إدخال وتشغيله عند كتابة أي شخص لأي شيء. لحسن الحظ لدينا حدث يسمى `onChange()` لخدمة هذا الغرض. PS - وهنا طريقة أخرى لربط `this` في وظيفة ستشمل خطوتك التالية إنشاء مربع إدخال وتشغيله عند كتابة أي شخص لأي شيء. لحسن الحظ لدينا حدث يسمى `onChange()` لخدمة هذا الغرض. PS - وهنا طريقة أخرى لربط `this` في وظيفة
`<input onChange = {this.handleChange.bind(this)}/> ```
` <input onChange = {this.handleChange.bind(this)}/>
```
لكن هذا لن يخدم هدفك. على الرغم من أنك قد تشعر أن عملها. إذن ما يحدث هنا هو تحديثات النص من المتصفح وليس الدولة. لذا ، لتصحيح ذلك ، سنضيف سمة `value` `this.state.input` على `this.state.input` لعنصر الإدخال الذي سيجعل الإدخال يتحكم في الحالة. لكن هذا لن يخدم هدفك. على الرغم من أنك قد تشعر أن عملها. إذن ما يحدث هنا هو تحديثات النص من المتصفح وليس الدولة. لذا ، لتصحيح ذلك ، سنضيف سمة `value` `this.state.input` على `this.state.input` لعنصر الإدخال الذي سيجعل الإدخال يتحكم في الحالة.
`<input value = {this.state.input} onChange = {this.handleChange.bind(this)}/> ```
` <input value = {this.state.input} onChange = {this.handleChange.bind(this)}/>
```
يمكن أن يكون من الصعب جدًا استيعابها ولكن لجعل الأمور أكثر وضوحًا ، جرّب إزالة أمر `onChange` بأكمله حتى تبدو الشفرة مثل هذا يمكن أن يكون من الصعب جدًا استيعابها ولكن لجعل الأمور أكثر وضوحًا ، جرّب إزالة أمر `onChange` بأكمله حتى تبدو الشفرة مثل هذا
`<input value = {this.state.input}/> ```
` <input value = {this.state.input}/>
```
الآن قم بتشغيل الاختبارات مرة أخرى هل أنت قادر على كتابة أي شيء؟ سيكون الجواب عليه "لا" لأن مربع الإدخال الخاص بك يحصل على قيمة من `input` متغير الحالة حيث لا يوجد تغيير في `input` الحالة (سلسلة فارغة مبدئياً) والذي سيحدث فقط عندما تقوم بتشغيل الدالة `handleChange()` والتي سوف يحدث فقط عندما يكون لديك معالج حدث مثل `onChange()` ومن ثم ستظل السلسلة داخل مربع الإدخال كما هي ، أي سلسلة فارغة. الآن قم بتشغيل الاختبارات مرة أخرى هل أنت قادر على كتابة أي شيء؟ سيكون الجواب عليه "لا" لأن مربع الإدخال الخاص بك يحصل على قيمة من `input` متغير الحالة حيث لا يوجد تغيير في `input` الحالة (سلسلة فارغة مبدئياً) والذي سيحدث فقط عندما تقوم بتشغيل الدالة `handleChange()` والتي سوف يحدث فقط عندما يكون لديك معالج حدث مثل `onChange()` ومن ثم ستظل السلسلة داخل مربع الإدخال كما هي ، أي سلسلة فارغة.

View File

@ -12,7 +12,8 @@ localeTitle: إنشاء مكون React
## حل ## حل
`class MyComponent extends React.Component { ```javascript
class MyComponent extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
} }
@ -25,7 +26,7 @@ localeTitle: إنشاء مكون React
); );
// change code above this line // change code above this line
} }
}; };
` ```
لاحظ أنك لا تحتاج إلى وضع علامات اقتباس حول النص ، لأنه عندما تعمل مع JSX يتم التعامل معه على أنه HTML. تحقق أيضًا من صحة التهجئة والحالة وعلامات الترقيم! إذا كان كل هذا التعليمة البرمجية يبدو غريبا ، اذهب إلى الاطلاع على بعض المواد الرائعة الموجودة على Javascript ES6 هنا على freeCodeCamp. لاحظ أنك لا تحتاج إلى وضع علامات اقتباس حول النص ، لأنه عندما تعمل مع JSX يتم التعامل معه على أنه HTML. تحقق أيضًا من صحة التهجئة والحالة وعلامات الترقيم! إذا كان كل هذا التعليمة البرمجية يبدو غريبا ، اذهب إلى الاطلاع على بعض المواد الرائعة الموجودة على Javascript ES6 هنا على freeCodeCamp.

View File

@ -6,7 +6,8 @@ localeTitle: إنشاء مكون Stateful
#### تلميح 1: #### تلميح 1:
`class StatefulComponent extends React.Component { ```JSX
class StatefulComponent extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
// initialize state here // initialize state here
@ -20,8 +21,8 @@ localeTitle: إنشاء مكون Stateful
</div> </div>
); );
} }
}; };
` ```
## حل ## حل

View File

@ -14,10 +14,11 @@ localeTitle: إنشاء مكون وظيفي عديم الحالة
تتم إضافة وظيفة إرجاع مثل هذا تتم إضافة وظيفة إرجاع مثل هذا
`return( ```jsx
return(
<return elements> <return elements>
); );
` ```
### حل ### حل

View File

@ -15,9 +15,10 @@ localeTitle: تحديد فئة HTML في JSX
## حل ## حل
`const JSX = ( ```javascript
const JSX = (
<div className = "myDiv"> <div className = "myDiv">
<h1>Add a class to this div</h1> <h1>Add a class to this div</h1>
</div> </div>
); );
` ```

View File

@ -6,7 +6,8 @@ localeTitle: تعرف على علامات JSX ذاتية الإغلاق
## تلميح 1: ## تلميح 1:
`const JSX = ( ```js
const JSX = (
<div> <div>
{/* remove comment and change code below this line // Remember that comments in JSX have parentheses. {/* remove comment and change code below this line // Remember that comments in JSX have parentheses.
<h2>Welcome to React!</h2> <br > // ? <h2>Welcome to React!</h2> <br > // ?
@ -14,8 +15,8 @@ localeTitle: تعرف على علامات JSX ذاتية الإغلاق
<hr > // ? <hr > // ?
remove comment and change code above this line */} // Remember that comments in JSX have parentheses. remove comment and change code above this line */} // Remember that comments in JSX have parentheses.
</div> </div>
); );
` ```
## حل ## حل

View File

@ -12,7 +12,8 @@ localeTitle: تحسين Re-Renders مع shouldComponentUpdate
بالنسبة لهذا الحل ، ستستخدم عبارة `if/then` للتحقق مما إذا كانت قيمة `nextProps` متساوية. تختلف `nextProps` عن `props` في أنها قيمة لم يتم تقديمها في واجهة المستخدم بعد ، لذا في أسلوب `shouldComponentUpdate()` ، فأنت تطلب بشكل أساسي إذنًا لتحديث واجهة المستخدم بقيمة `nextProps` . بالنسبة لهذا الحل ، ستستخدم عبارة `if/then` للتحقق مما إذا كانت قيمة `nextProps` متساوية. تختلف `nextProps` عن `props` في أنها قيمة لم يتم تقديمها في واجهة المستخدم بعد ، لذا في أسلوب `shouldComponentUpdate()` ، فأنت تطلب بشكل أساسي إذنًا لتحديث واجهة المستخدم بقيمة `nextProps` .
`class OnlyEvens extends React.Component { ```jsx
class OnlyEvens extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
} }
@ -34,9 +35,9 @@ localeTitle: تحسين Re-Renders مع shouldComponentUpdate
render() { render() {
return <h1>{this.props.value}</h1> return <h1>{this.props.value}</h1>
} }
}; };
class Controller extends React.Component { class Controller extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -57,5 +58,5 @@ localeTitle: تحسين Re-Renders مع shouldComponentUpdate
</div> </div>
); );
} }
}; };
` ```

View File

@ -16,7 +16,8 @@ localeTitle: تمرير رد الاتصال على النحو الدعائم
### حل ### حل
`class MyApp extends React.Component { ```javascript
class MyApp extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -41,5 +42,5 @@ localeTitle: تمرير رد الاتصال على النحو الدعائم
</div> </div>
); );
} }
}; };
` ```

View File

@ -6,11 +6,12 @@ localeTitle: تمرير صفيف كما الدعائم
لتمرير مصفوفة كبروب ، يجب أن يتم الإعلان أولاً عن صفيف على أنه دعم "المهام" على كل مكون من المكونات التي سيتم تقديمها: لتمرير مصفوفة كبروب ، يجب أن يتم الإعلان أولاً عن صفيف على أنه دعم "المهام" على كل مكون من المكونات التي سيتم تقديمها:
`const List= (props) => { ```javascript
const List= (props) => {
return <p></p> return <p></p>
}; };
class ToDo extends React.Component { class ToDo extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
} }
@ -25,17 +26,18 @@ localeTitle: تمرير صفيف كما الدعائم
</div> </div>
); );
} }
}; };
` ```
ثم ، يجب التعامل مع الدعائم داخل مكون "قائمة": ثم ، يجب التعامل مع الدعائم داخل مكون "قائمة":
`const List= (props) => { ```javascript
const List= (props) => {
return <p>{props.tasks.join(", ")}</p> return <p>{props.tasks.join(", ")}</p>
}; };
// ... same as above // ... same as above
` ```
يتم استخدام طريقة `.join(", ")` لأخذ كل عنصر من داخل الصفيف ثم `.join(", ")` إلى سلسلة ليتم عرضها. يتم استخدام طريقة `.join(", ")` لأخذ كل عنصر من داخل الصفيف ثم `.join(", ")` إلى سلسلة ليتم عرضها.

View File

@ -8,8 +8,9 @@ localeTitle: تمرير الدعائم إلى مكون وظيفي عديم ال
حدد تاريخًا مسمى للدعم في مكون التقويم كما يلي: حدد تاريخًا مسمى للدعم في مكون التقويم كما يلي:
`<CurrentDate date={Date()} /> ```jsx
` <CurrentDate date={Date()} />
```
\` \`
@ -21,15 +22,16 @@ localeTitle: تمرير الدعائم إلى مكون وظيفي عديم ال
قم بتعيين تاريخ مسمى للدعم في مكون التقويم كما يلي وقم بعرضه في مكون التقويم ، مثل: قم بتعيين تاريخ مسمى للدعم في مكون التقويم كما يلي وقم بعرضه في مكون التقويم ، مثل:
`const CurrentDate = (props) => { ```jsx
const CurrentDate = (props) => {
return ( return (
<div> <div>
<p>The current date is: {props.date}</p> <p>The current date is: {props.date}</p>
</div> </div>
); );
}; };
class Calendar extends React.Component { class Calendar extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
} }
@ -41,5 +43,5 @@ localeTitle: تمرير الدعائم إلى مكون وظيفي عديم ال
</div> </div>
); );
} }
}; };
` ```

View File

@ -6,7 +6,8 @@ localeTitle: تمرير حالة الدعائم إلى مكونات الأطفا
في هذا التحدي ، سنمرر الدولة ، ولكن بما أن الحالة محلية لمكونها الأم ، يجب أن نستخدم **الدعائم** لتمريرها إلى المكون الفرعي. سيسمح لنا استخدام الدعائم في المكونات الفرعية بالاحتفاظ بكل بيانات الحالة في المكون الرئيسي ويمكننا تمرير البيانات في اتجاه واحد إلى مكونات الأطفال. في هذا التحدي ، سنمرر الدولة ، ولكن بما أن الحالة محلية لمكونها الأم ، يجب أن نستخدم **الدعائم** لتمريرها إلى المكون الفرعي. سيسمح لنا استخدام الدعائم في المكونات الفرعية بالاحتفاظ بكل بيانات الحالة في المكون الرئيسي ويمكننا تمرير البيانات في اتجاه واحد إلى مكونات الأطفال.
`class MyApp extends React.Component { ```javascript
class MyApp extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -22,9 +23,9 @@ localeTitle: تمرير حالة الدعائم إلى مكونات الأطفا
</div> </div>
); );
} }
}; };
class Navbar extends React.Component { class Navbar extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
} }
@ -37,5 +38,5 @@ localeTitle: تمرير حالة الدعائم إلى مكونات الأطفا
</div> </div>
); );
} }
}; };
` ```

View File

@ -6,7 +6,8 @@ localeTitle: تقديم مكون فئة إلى DOM
من المفترض أن ينتهي رمزك بالظهور على النحو التالي: من المفترض أن ينتهي رمزك بالظهور على النحو التالي:
`class TypesOfVehicles extends React.Component { ```javascript
class TypesOfVehicles extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
} }
@ -19,9 +20,9 @@ localeTitle: تقديم مكون فئة إلى DOM
</div> </div>
); );
} }
} }
ReactDOM.render(<TypesOfVehicles />,'node-id') ReactDOM.render(<TypesOfVehicles />,'node-id')
` ```
قد يكون بناء جملة ReactDOM.render خادعاً قليلاً ، تحتاج إلى استخدام أقواس المثلث عند المرور في مكون Class. كما يتم الإعلان عن المكونين الفرعيين خلف الكواليس ، مما قد يكون مربكًا إذا كنت معتادًا على جميع المتغيرات التي يتم تحديدها في محرر الشفرة ومرئية أمامك. قد يكون بناء جملة ReactDOM.render خادعاً قليلاً ، تحتاج إلى استخدام أقواس المثلث عند المرور في مكون Class. كما يتم الإعلان عن المكونين الفرعيين خلف الكواليس ، مما قد يكون مربكًا إذا كنت معتادًا على جميع المتغيرات التي يتم تحديدها في محرر الشفرة ومرئية أمامك.

View File

@ -6,12 +6,14 @@ localeTitle: تقديم عناصر HTML إلى DOM
لتقديم عنصر إلى DOM ، نستخدم بناء الجملة التالي لتقديم عنصر إلى DOM ، نستخدم بناء الجملة التالي
`ReactDOM.render(<item to be rendered>, <where to be rendered>); ```javascript
` ReactDOM.render(<item to be rendered>, <where to be rendered>);
```
## حل ## حل
بعد بناء الجملة ، نضيف هذا السطر من التعليمة البرمجية لتحويل عنصر JSX إلى div بمعرف عقدة التحدي. بعد بناء الجملة ، نضيف هذا السطر من التعليمة البرمجية لتحويل عنصر JSX إلى div بمعرف عقدة التحدي.
`ReactDOM.render(JSX,document.getElementById('challenge-node')); ```javascript
` ReactDOM.render(JSX,document.getElementById('challenge-node'));
```

View File

@ -8,15 +8,16 @@ localeTitle: تجعل رد فعل على الخادم مع renderToString
يمكنك تمرير `class` `.renderToString()` إلى `.renderToString()` مثلما تقوم بتمرير مكون إلى طريقة `render` . يمكنك تمرير `class` `.renderToString()` إلى `.renderToString()` مثلما تقوم بتمرير مكون إلى طريقة `render` .
`class App extends React.Component { ```jsx
class App extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
} }
render() { render() {
return <div/> return <div/>
} }
}; };
// change code below this line // change code below this line
ReactDOMServer.renderToString(<App />); ReactDOMServer.renderToString(<App />);
` ```

View File

@ -6,7 +6,8 @@ localeTitle: تقديم الدولة في واجهة المستخدم بطريق
#### تلميح 1: #### تلميح 1:
`class MyComponent extends React.Component { ```JSX
class MyComponent extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -26,12 +27,13 @@ localeTitle: تقديم الدولة في واجهة المستخدم بطريق
</div> </div>
); );
} }
}; };
` ```
## حل ## حل
`class MyComponent extends React.Component { ```JSX
class MyComponent extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -50,5 +52,5 @@ localeTitle: تقديم الدولة في واجهة المستخدم بطريق
</div> </div>
); );
} }
}; };
` ```

View File

@ -12,16 +12,17 @@ localeTitle: استعراض استخدام الدعائم مع مكونات وظ
### حل ### حل
`const Camper = props => (<p>{props.name}</p>); ```javascript
const Camper = props => (<p>{props.name}</p>);
Camper.defaultProps = { Camper.defaultProps = {
name: 'CamperBot' name: 'CamperBot'
}; };
Camper.propTypes = { Camper.propTypes = {
name: PropTypes.string.isRequired name: PropTypes.string.isRequired
}; };
` ```
### رابط ذو صلة ### رابط ذو صلة

View File

@ -6,8 +6,9 @@ localeTitle: استخدم && من أجل شرطي أكثر موجزًا
المثال المعطى هو المثال المعطى هو
`{condition && <p>markup</p>} ```
` {condition && <p>markup</p>}
```
والذي يظهر أدناه باستخدام حالة this.state.dinnerCoined boolean. إذا كان الأمر المنطقي صحيحًا ، فسيتم عرض الترميز المضمن في {} مع الشرط ، وإلا فلن يتم عرضه والذي يظهر أدناه باستخدام حالة this.state.dinnerCoined boolean. إذا كان الأمر المنطقي صحيحًا ، فسيتم عرض الترميز المضمن في {} مع الشرط ، وإلا فلن يتم عرضه

View File

@ -10,8 +10,9 @@ localeTitle: استخدم تعبير Ternary للعرض الشرطي
يتكون المشغل الثلاثي من ثلاثة أجزاء ، ولكن يمكنك الجمع بين عدة تعبيرات ثلاثية معًا. وإليك البنية الأساسية: يتكون المشغل الثلاثي من ثلاثة أجزاء ، ولكن يمكنك الجمع بين عدة تعبيرات ثلاثية معًا. وإليك البنية الأساسية:
`condition ? expressionIfTrue : expressionIfFalse ```
` condition ? expressionIfTrue : expressionIfFalse
```
## حل ## حل

View File

@ -12,8 +12,9 @@ localeTitle: استخدم جافا سكريبت المتقدمة في طريقة
### حل ### حل
`const answer = possibleAnswers[this.state.randomIndex]; ```js
` const answer = possibleAnswers[this.state.randomIndex];
```
بعد ذلك ، أدخل "الإجابة" الخاصة بك في علامات p. تأكد من لفها بأقواس معقوفة `{ }` . بعد ذلك ، أدخل "الإجابة" الخاصة بك في علامات p. تأكد من لفها بأقواس معقوفة `{ }` .

View File

@ -6,28 +6,31 @@ localeTitle: استخدام الدعائم الافتراضية
هذا التحدي قد قمت بتعريف دعم افتراضي لمكون ShoppingCart هذا التحدي قد قمت بتعريف دعم افتراضي لمكون ShoppingCart
`const ShoppingCart = (props) => { ```javascript
const ShoppingCart = (props) => {
return ( return (
<div> <div>
<h1>Shopping Cart Component</h1> <h1>Shopping Cart Component</h1>
</div> </div>
) )
}; };
` ```
لإعلان دعامة افتراضية ، فإن الصيغة التي يجب اتباعها هي لإعلان دعامة افتراضية ، فإن الصيغة التي يجب اتباعها هي
`itemName.defaultProps = { ```javascript
itemName.defaultProps = {
prop-x: value, prop-x: value,
prop-y: value prop-y: value
} }
` ```
باتباع "بناء الجملة" ، يجب أن يتم تعريف التعليمة البرمجية التالية أدناه التعليمات البرمجية المحددة باتباع "بناء الجملة" ، يجب أن يتم تعريف التعليمة البرمجية التالية أدناه التعليمات البرمجية المحددة
`ShoppingCart.defaultProps = { ```javascript
ShoppingCart.defaultProps = {
items: 0 items: 0
} }
` ```
هذا يعلن دعامة تسمى "العناصر" بقيمة "0". هذا يعلن دعامة تسمى "العناصر" بقيمة "0".

View File

@ -13,9 +13,10 @@ localeTitle: استخدم React لتقديم العناصر المتداخلة
في هذا الاختبار ، قمنا بتعريف مكونين وظيفيين عديمي الأهلية ، أي استخدام وظائف JavaScript. تذكر ، بمجرد إنشاء مكون ، يمكن تقديمه بنفس طريقة علامة HTML ، باستخدام اسم المكون داخل أقواس فتح وإغلاق HTML. على سبيل المثال ، لتضمين مكون يدعى Dog داخل مكون رئيسي يسمى Animals ، يمكنك ببساطة إرجاع مكون Dog من مكون الحيوانات مثل: في هذا الاختبار ، قمنا بتعريف مكونين وظيفيين عديمي الأهلية ، أي استخدام وظائف JavaScript. تذكر ، بمجرد إنشاء مكون ، يمكن تقديمه بنفس طريقة علامة HTML ، باستخدام اسم المكون داخل أقواس فتح وإغلاق HTML. على سبيل المثال ، لتضمين مكون يدعى Dog داخل مكون رئيسي يسمى Animals ، يمكنك ببساطة إرجاع مكون Dog من مكون الحيوانات مثل:
`return ( ```javascript
return (
<Dog /> <Dog />
) )
` ```
جرب هذا مع مكونات TypesOfFruit و Fruits. جرب هذا مع مكونات TypesOfFruit و Fruits.

View File

@ -19,7 +19,8 @@ localeTitle: استخدم الدولة لتبديل عنصر
## حل: ## حل:
`class MyComponent extends React.Component { ```jsx
class MyComponent extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -57,5 +58,5 @@ localeTitle: استخدم الدولة لتبديل عنصر
); );
} }
} }
}; };
` ```

View File

@ -6,10 +6,11 @@ localeTitle: اكتب مكون React من سكراتش
في هذا التحدي ، نرغب في إنشاء مكون تفاعل `class` (يمكن أن تكون مكونات React مكونات `class` أو مكونات `function` ). جميع مكونات الفصل لدينا ستكون `React.Component` لـ `React.Component` . على سبيل المثال ، يمكننا البدء في إنشاء مكون يسمى `FirstComponent` مع: في هذا التحدي ، نرغب في إنشاء مكون تفاعل `class` (يمكن أن تكون مكونات React مكونات `class` أو مكونات `function` ). جميع مكونات الفصل لدينا ستكون `React.Component` لـ `React.Component` . على سبيل المثال ، يمكننا البدء في إنشاء مكون يسمى `FirstComponent` مع:
`class FirstComponent extends React.Component { ```javascript
class FirstComponent extends React.Component {
}; };
` ```
نحتاج أيضًا إلى التأكد من تعريف `constructor` لفئتنا الجديدة. ومن أفضل الممارسات لاستدعاء أي مكون `constructor` مع `super` ولتمرير `props` على حد سواء. `super` تسحب `constructor` الفئة الأصل المكون لدينا (في هذه الحالة `React.Component` ). الآن ، تبدو الشفرة الخاصة بمكوننا كما يلي: نحتاج أيضًا إلى التأكد من تعريف `constructor` لفئتنا الجديدة. ومن أفضل الممارسات لاستدعاء أي مكون `constructor` مع `super` ولتمرير `props` على حد سواء. `super` تسحب `constructor` الفئة الأصل المكون لدينا (في هذه الحالة `React.Component` ). الآن ، تبدو الشفرة الخاصة بمكوننا كما يلي:
@ -23,7 +24,8 @@ localeTitle: اكتب مكون React من سكراتش
الآن كل ما تبقى القيام به هو تحديد ما `render` ! نقوم بذلك عن طريق استدعاء طريقة `render` المكون ، وإرجاع رمز JSX الخاص بنا: الآن كل ما تبقى القيام به هو تحديد ما `render` ! نقوم بذلك عن طريق استدعاء طريقة `render` المكون ، وإرجاع رمز JSX الخاص بنا:
`class FirstComponent extends React.Component { ```javascript
class FirstComponent extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
} }
@ -32,7 +34,7 @@ localeTitle: اكتب مكون React من سكراتش
// The JSX code you put here is what your component will render // The JSX code you put here is what your component will render
); );
} }
}; };
` ```
بمجرد وجود شفرة JSX الخاصة بك ، اكتمل المكون الخاص بك! إذا كنت تريد تعليمي أكثر دقة من مكونات React [كتب](https://medium.freecodecamp.org/how-to-write-your-first-react-js-component-d728d759cabc) سامر بونا [مقالة رائعة](https://medium.freecodecamp.org/how-to-write-your-first-react-js-component-d728d759cabc) . بمجرد وجود شفرة JSX الخاصة بك ، اكتمل المكون الخاص بك! إذا كنت تريد تعليمي أكثر دقة من مكونات React [كتب](https://medium.freecodecamp.org/how-to-write-your-first-react-js-component-d728d759cabc) سامر بونا [مقالة رائعة](https://medium.freecodecamp.org/how-to-write-your-first-react-js-component-d728d759cabc) .

View File

@ -36,7 +36,8 @@ localeTitle: اكتب عداد بسيط
## حل: ## حل:
`class Counter extends React.Component { ```JSX
class Counter extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -63,5 +64,5 @@ localeTitle: اكتب عداد بسيط
</div> </div>
); );
} }
}; };
` ```

View File

@ -12,19 +12,22 @@ localeTitle: قم بإنشاء مخزن Redux
### الخطوة 1. أعلن المتغير. ### الخطوة 1. أعلن المتغير.
`const yourVariableName; ```javascript
` const yourVariableName;
```
### الخطوة 2. تعيين المتغير الخاص بك إلى طريقة. ### الخطوة 2. تعيين المتغير الخاص بك إلى طريقة.
`const yourVariableName = yourMethodName(); ```javascript
` const yourVariableName = yourMethodName();
```
تلميح: ضع في اعتبارك أن طريقة `createStore()` متاحة من الكائن Redux. على سبيل المثال: `Redux.createStore()` تلميح: ضع في اعتبارك أن طريقة `createStore()` متاحة من الكائن Redux. على سبيل المثال: `Redux.createStore()`
### الخطوة 3. تمرير في جدال للطريقة الخاصة بك. ### الخطوة 3. تمرير في جدال للطريقة الخاصة بك.
`const yourVariableName = yourMethodName(yourArgumentName); ```javascript
` const yourVariableName = yourMethodName(yourArgumentName);
```
حظا طيبا وفقك الله! حظا طيبا وفقك الله!

View File

@ -8,10 +8,11 @@ localeTitle: قم بتعريف عمل الخالق
يتم تعريف الدالة باستخدام بناء الجملة التالي: يتم تعريف الدالة باستخدام بناء الجملة التالي:
`functionName(){ ```javascript
functionName(){
console.log("Do something"); console.log("Do something");
} }
` ```
حيث يمكن تغيير console.log حسب الحاجة. حيث يمكن تغيير console.log حسب الحاجة.
@ -21,7 +22,8 @@ localeTitle: قم بتعريف عمل الخالق
### حل ### حل
`function actionCreator(){ ```javascript
function actionCreator(){
return action; return action;
} }
` ```

View File

@ -6,11 +6,12 @@ localeTitle: التعامل مع العمل في المتجر
### حل ### حل
`const defaultState = { ```javascript
const defaultState = {
login: false login: false
}; };
const reducer = (state = defaultState, action) => { const reducer = (state = defaultState, action) => {
// change code below this line // change code below this line
if (action.type === 'LOGIN') { if (action.type === 'LOGIN') {
return { return {
@ -20,13 +21,13 @@ localeTitle: التعامل مع العمل في المتجر
return defaultState return defaultState
}; };
// change code above this line // change code above this line
}; };
const store = Redux.createStore(reducer); const store = Redux.createStore(reducer);
const loginAction = () => { const loginAction = () => {
return { return {
type: 'LOGIN' type: 'LOGIN'
} }
}; };
` ```

View File

@ -20,36 +20,39 @@ localeTitle: تسجيل مستمع المتجر
وظيفة رد الاتصال هي ببساطة دالة يتم استدعائها بعد إجراء وظيفة أخرى يتم تنفيذها. في العالم الحقيقي ، قد يكون شيء من هذا القبيل: وظيفة رد الاتصال هي ببساطة دالة يتم استدعائها بعد إجراء وظيفة أخرى يتم تنفيذها. في العالم الحقيقي ، قد يكون شيء من هذا القبيل:
`// You drop your car off at the mechanic and you want the shop to 'call you back' when your car is fixed. ```javascript
let carIsBroken = true; // You drop your car off at the mechanic and you want the shop to 'call you back' when your car is fixed.
const callCarOwner = () => console.log('Hello your car is done!'); let carIsBroken = true;
const fixCar = (carIsBroken, callCarOwner) => { const callCarOwner = () => console.log('Hello your car is done!');
const fixCar = (carIsBroken, callCarOwner) => {
if (carIsBroken === true) { if (carIsBroken === true) {
carIsBroken = false; carIsBroken = false;
} }
console.log(carIsBroken); console.log(carIsBroken);
// After the car is fixed, the last thing we do is call the car owner - that's our 'callback function'. // After the car is fixed, the last thing we do is call the car owner - that's our 'callback function'.
callCarOwner(); callCarOwner();
} }
fixCar(carIsBroken, callCarOwner); fixCar(carIsBroken, callCarOwner);
` ```
### كيف تزيد من عدد المتغيرات؟ ### كيف تزيد من عدد المتغيرات؟
يمكننا القيام بذلك عن طريق استخدام عامل التشغيل "+ =". يمكننا القيام بذلك عن طريق استخدام عامل التشغيل "+ =".
`let count = 1; ```javascript
const addOne = () => count +=1; let count = 1;
` const addOne = () => count +=1;
```
### كيف يمكنك تمرير وظيفة إلى طريقة؟ ### كيف يمكنك تمرير وظيفة إلى طريقة؟
يمكننا تمرير وظيفة إلى طريقة بالطريقة نفسها التي قد نمرر بها متغيرًا إلى طريقة ما. فقط قم بتمريرها كحجة! يمكننا تمرير وظيفة إلى طريقة بالطريقة نفسها التي قد نمرر بها متغيرًا إلى طريقة ما. فقط قم بتمريرها كحجة!
`function sayHi() { ```javascript
function sayHi() {
console.log('Hi!'); console.log('Hi!');
} }
store.subscribe(sayHi); store.subscribe(sayHi);
` ```
تريد تحديث هذا؟ [تحرير هذا كعب الرهان على جيثب.](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/front-end-libraries/redux/register-a-store-listener/index.md) تريد تحديث هذا؟ [تحرير هذا كعب الرهان على جيثب.](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/front-end-libraries/redux/register-a-store-listener/index.md)

View File

@ -10,13 +10,14 @@ localeTitle: استخدم const for Action Types
يمكنك `type: 'LOGIN'` الهجاء `type: 'LOGIN'` بشكل صحيح في منشئ الفعل الخاص بك ولكن `type: 'LOGN'` الخطأ `type: 'LOGN'` في المخفض كما هو موضح أدناه. يمكنك `type: 'LOGIN'` الهجاء `type: 'LOGIN'` بشكل صحيح في منشئ الفعل الخاص بك ولكن `type: 'LOGN'` الخطأ `type: 'LOGN'` في المخفض كما هو موضح أدناه.
`const loginUser = () => { ```
const loginUser = () => {
return { return {
type: 'LOGIN' type: 'LOGIN'
} }
}; };
const authReducer = (state = defaultState, action) => { const authReducer = (state = defaultState, action) => {
switch (action.type) { switch (action.type) {
@ -35,29 +36,30 @@ localeTitle: استخدم const for Action Types
} }
}; };
` ```
باستخدام const لنوع الإجراء ، لن يهم ما إذا كانت السلسلة تحتوي على أخطاء إملائية لأن كل من رمز تبديل المُخفض ونوع الإجراء `const` نفس `const` . باستخدام `const` قد يؤدي أيضا محرر التعليمات البرمجية ليشير إلى `const` كما كنت تكتب عليه، وبالتالي تقليل فرصة mispelling و `const` . باستخدام const لنوع الإجراء ، لن يهم ما إذا كانت السلسلة تحتوي على أخطاء إملائية لأن كل من رمز تبديل المُخفض ونوع الإجراء `const` نفس `const` . باستخدام `const` قد يؤدي أيضا محرر التعليمات البرمجية ليشير إلى `const` كما كنت تكتب عليه، وبالتالي تقليل فرصة mispelling و `const` .
سيظهر الرمز الموضح أدناه. سيظهر الرمز الموضح أدناه.
`const LOGIN = 'blahblahblah'; ```
const LOGOUT = 'wahwahwahwah'; const LOGIN = 'blahblahblah';
const LOGOUT = 'wahwahwahwah';
const loginUser = () => { const loginUser = () => {
return { return {
type: LOGIN type: LOGIN
} }
}; };
const logoutUser = () => { const logoutUser = () => {
return { return {
type: LOGOUT type: LOGOUT
} }
}; };
const authReducer = (state = defaultState, action) => { const authReducer = (state = defaultState, action) => {
switch (action.type) { switch (action.type) {
@ -76,5 +78,5 @@ localeTitle: استخدم const for Action Types
} }
}; };
` ```

View File

@ -8,17 +8,19 @@ localeTitle: إنشاء CSS القابل لإعادة الاستخدام مع Mi
لإنشاء مزيج يجب اتباع النظام التالي: لإنشاء مزيج يجب اتباع النظام التالي:
`@mixin custom-mixin-name($param1, $param2, ....) { ```scss
@mixin custom-mixin-name($param1, $param2, ....) {
// CSS Properties Here... // CSS Properties Here...
} }
` ```
ولاستخدامه في العنصر (العناصر) ، يجب عليك استخدام `@include` يليه اسم `Mixin` الخاص بك ، على النحو التالي: ولاستخدامه في العنصر (العناصر) ، يجب عليك استخدام `@include` يليه اسم `Mixin` الخاص بك ، على النحو التالي:
`element { ```scss
element {
@include custom-mixin-name(value1, value2, ....); @include custom-mixin-name(value1, value2, ....);
} }
` ```
* * * * * *
@ -28,19 +30,20 @@ localeTitle: إنشاء CSS القابل لإعادة الاستخدام مع Mi
#### HTML #### HTML
` ```html
<h4>This text needs a Shadow!</h4> <h4>This text needs a Shadow!</h4>
` ```
#### SASS _(مكتوبة في بناء جملة SCSS)_ #### SASS _(مكتوبة في بناء جملة SCSS)_
`@mixin custom-text-shadow($offsetX, $offsetY, $blurRadius, $color) { ```scss
@mixin custom-text-shadow($offsetX, $offsetY, $blurRadius, $color) {
-webkit-text-shadow: $offsetX, $offsetY, $blurRadius, $color; -webkit-text-shadow: $offsetX, $offsetY, $blurRadius, $color;
-moz-text-shadow: $offsetX, $offsetY, $blurRadius, $color; -moz-text-shadow: $offsetX, $offsetY, $blurRadius, $color;
-ms-text-shadow: $offsetX, $offsetY, $blurRadius, $color; -ms-text-shadow: $offsetX, $offsetY, $blurRadius, $color;
text-shadow: $offsetX, $offsetY, $blurRadius, $color; text-shadow: $offsetX, $offsetY, $blurRadius, $color;
} }
h2 { h2 {
@include custom-text-shadow(1px, 3px, 5px, #999999) @include custom-text-shadow(1px, 3px, 5px, #999999)
} }
` ```

View File

@ -9,17 +9,18 @@ localeTitle: عش المغلق مع ساس
## مثال ## مثال
`.title{ ```sass
.title{
strong{} strong{}
em{} em{}
} }
// This will be compiled into: // This will be compiled into:
.title{} .title{}
.title strong{} .title strong{}
.title em{} .title em{}
` ```
## تلميح 1: ## تلميح 1:

View File

@ -8,17 +8,19 @@ localeTitle: استخدمfor لإنشاء Sass Loop
* ل - من خلال حلقة: * ل - من خلال حلقة:
`@for $i from <start number> through <end number> { ```sass
@for $i from <start number> through <end number> {
// some CSS // some CSS
} }
` ```
* ل- للحلقة: * ل- للحلقة:
`@for $i from <start number> to <end number> { ```sass
@for $i from <start number> to <end number> {
// some CSS // some CSS
} }
` ```
لاحظ أن الاختلاف الرئيسي هو أن "البداية إلى النهاية" **تستبعد** الرقم النهائي ، و "البدء من خلال النهاية" **يتضمن** الرقم النهائي. لاحظ أن الاختلاف الرئيسي هو أن "البداية إلى النهاية" **تستبعد** الرقم النهائي ، و "البدء من خلال النهاية" **يتضمن** الرقم النهائي.
@ -26,32 +28,35 @@ localeTitle: استخدمfor لإنشاء Sass Loop
* ل - من خلال حلقة: * ل - من خلال حلقة:
`@for $i from 1 through 3 { ```sass
@for $i from 1 through 3 {
// some CSS // some CSS
} }
// 1 2 // 1 2
` ```
* ل- للحلقة: * ل- للحلقة:
`@for $i from 1 to 3 { ```sass
@for $i from 1 to 3 {
// some CSS // some CSS
} }
// 1 2 3 // 1 2 3
` ```
3. المبدأ التوجيهي من [المبادئ التوجيهية SASS](https://sass-guidelin.es/#loops) 3. المبدأ التوجيهي من [المبادئ التوجيهية SASS](https://sass-guidelin.es/#loops)
قد تكون حلقة `@for` مفيدة عند دمجها مع CSS `:nth-*` pseudo-classes. باستثناء هذه السيناريوهات ، تفضل حلقة `@each` إذا كان عليك التكرار أكثر من شيء ما. قد تكون حلقة `@for` مفيدة عند دمجها مع CSS `:nth-*` pseudo-classes. باستثناء هذه السيناريوهات ، تفضل حلقة `@each` إذا كان عليك التكرار أكثر من شيء ما.
`@for $i from 1 through 10 { ```sass
@for $i from 1 through 10 {
.foo:nth-of-type(#{$i}) { .foo:nth-of-type(#{$i}) {
border-color: hsl($i * 36, 50%, 50%); border-color: hsl($i * 36, 50%, 50%);
} }
} }
` ```
استخدم دائمًا `$i` كاسم متغير للالتزام بالاتفاقية المعتادة وما لم يكن لديك سبب جيد بالفعل ، لا تستخدم الكلمة المفتاحية أبدًا: استخدمها دائمًا. العديد من المطورين لا يعرفون حتى Sass يقدم هذا الاختلاف. قد يؤدي استخدامها إلى الارتباك. استخدم دائمًا `$i` كاسم متغير للالتزام بالاتفاقية المعتادة وما لم يكن لديك سبب جيد بالفعل ، لا تستخدم الكلمة المفتاحية أبدًا: استخدمها دائمًا. العديد من المطورين لا يعرفون حتى Sass يقدم هذا الاختلاف. قد يؤدي استخدامها إلى الارتباك.

View File

@ -6,13 +6,15 @@ localeTitle: تسجيل المستخدمين الجدد
تأكد من تعديل الملفات الشخصية / الصلصال / الملف الشخصي.الخط 11: تأكد من تعديل الملفات الشخصية / الصلصال / الملف الشخصي.الخط 11:
`h1.border.center FCC Advanced Node and Express ```pug
` h1.border.center FCC Advanced Node and Express
```
إلى إلى
`h1.border.center Profile Home ```pug
` h1.border.center Profile Home
```
وإلا لن تمر الاختبارات وإلا لن تمر الاختبارات