Add languages Russian, Arabic, Chinese, Portuguese (#18305)
This commit is contained in:
committed by
mrugesh mohapatra
parent
09d3eca712
commit
2ca3a2093f
@ -0,0 +1,58 @@
|
||||
---
|
||||
id: 587d7b85367417b2b2512b3a
|
||||
title: Catch Arguments Passed in the Wrong Order When Calling a Function
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: Catch Arguments Passed in the Wrong Order When Calling a Function
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> استمرار المناقشة حول وظائف الاستدعاء ، فإن الخطأ التالي الذي يجب الانتباه إليه هو عندما يتم توفير وسيطات الدالة بترتيب غير صحيح. إذا كانت الوسيطات هي أنواع مختلفة ، مثل دالة تتوقع مصفوفة وعددًا صحيحًا ، فمن المحتمل أن يؤدي ذلك إلى حدوث خطأ في وقت التشغيل. إذا كانت الوسيطات من نفس النوع (كل الأعداد الصحيحة ، على سبيل المثال) ، فإن منطق الكود لن يكون ذا معنى. تأكد من توفير جميع الحجج المطلوبة ، بالترتيب الصحيح لتجنب هذه المشاكل. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> ترفع الدالة <code>raiseToPower</code> قاعدة إلى الأس. للأسف ، لا يتم استدعائه بشكل صحيح - قم بإصلاح الكود بحيث تكون قيمة <code>power</code> المتوقعة 8. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن تحدد شفرتك <code>power</code> المتغيرة بحيث تساوي 2 مرفوعة إلى الطاقة الثالثة ، وليس 3 مرفوعة إلى الطاقة الثانية.
|
||||
testString: 'assert(power == 8, "Your code should fix the variable <code>power</code> so it equals 2 raised to the 3rd power, not 3 raised to the 2nd power.");'
|
||||
- text: يجب أن تستخدم التعليمة البرمجية الخاصة بك الترتيب الصحيح للوسيطات الخاصة <code>raiseToPower</code> وظيفة <code>raiseToPower</code> .
|
||||
testString: 'assert(code.match(/raiseToPower\(\s*?base\s*?,\s*?exp\s*?\);/g), "Your code should use the correct order of the arguments for the <code>raiseToPower</code> function call.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function raiseToPower(b, e) {
|
||||
return Math.pow(b, e);
|
||||
}
|
||||
|
||||
let base = 2;
|
||||
let exp = 3;
|
||||
let power = raiseToPower(exp, base);
|
||||
console.log(power);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@ -0,0 +1,58 @@
|
||||
---
|
||||
id: 587d7b85367417b2b2512b39
|
||||
title: Catch Missing Open and Closing Parenthesis After a Function Call
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: الصيد المفقود وأشرطة الاختتام المفتوحة بعد استدعاء وظيفة
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> عندما لا تأخذ وظيفة أو طريقة أي حجج ، قد تنسى تضمين أقواس الفتح والإغلاق (الفارغة) عند الاتصال بها. في كثير من الأحيان يتم حفظ نتيجة استدعاء دالة في متغير لاستخدام أخرى في التعليمات البرمجية. يمكن الكشف عن هذا الخطأ عن طريق تسجيل قيم المتغير (أو أنواعها) إلى وحدة التحكم ورؤية أنه يتم تعيين واحد إلى مرجع دالة ، بدلاً من القيمة المتوقعة التي ترجعها الدالة. تختلف المتغيرات في المثال التالي: <blockquote style=";text-align:right;direction:rtl"> وظيفة myFunction () { <br> "أنت صخرة!" <br> } <br> السماح varOne = myFunction. // set to equal a a function <br> اترك varTwo = myFunction ()؛ // set يساوي السلسلة "You rock!" </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> قم <code>getNine</code> الكود بحيث يتم تعيين <code>result</code> المتغير إلى القيمة التي يتم إرجاعها من استدعاء الدالة <code>getNine</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن تقوم التعليمات البرمجية الخاصة بك بإصلاح <code>result</code> المتغيرة بحيث يتم تعيينها إلى الرقم الذي ترجع الدالة <code>getNine</code> .
|
||||
testString: 'assert(result == 9, "Your code should fix the variable <code>result</code> so it is set to the number that the function <code>getNine</code> returns.");'
|
||||
- text: يجب أن تقوم التعليمات البرمجية الخاصة بك باستدعاء الدالة <code>getNine</code> .
|
||||
testString: 'assert(code.match(/getNine\(\)/g).length == 2, "Your code should call the <code>getNine</code> function.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function getNine() {
|
||||
let x = 6;
|
||||
let y = 3;
|
||||
return x + y;
|
||||
}
|
||||
|
||||
let result = getNine;
|
||||
console.log(result);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@ -0,0 +1,60 @@
|
||||
---
|
||||
id: 587d7b84367417b2b2512b35
|
||||
title: Catch Misspelled Variable and Function Names
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: القبض على المتغيرات التي بها أخطاء في الأسماء والأسماء الدالة
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> تعتبر أساليب <code>console.log()</code> و <code>typeof</code> هما طريقتان أساسيتان للتحقق من القيم المتوسطة وأنواع مخرجات البرنامج. الآن حان الوقت للوصول إلى الأشكال الشائعة التي تتخذها الحشرات. هناك مشكلة واحدة في بناء الجملة يمكن أن تتطابق معها الطابعات السريعة مع الخطأ الإملائي المتواضع. الأحرف المستعرضة أو المفقودة أو غير المكتوبة بطريقة خاطئة في متغير أو اسم وظيفي سوف يبحث المتصفح عن كائن غير موجود - ويشكو في شكل خطأ مرجعي. متغير جافا سكريبت وأسماء الدالة حساسة لحالة الأحرف. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> قم <code>netWorkingCapital</code> الإملائيين في التعليمات البرمجية بحيث يعمل الحساب <code>netWorkingCapital</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: 'تحقق من هجاء المتغيرين المستخدم في حساب netWorkingCapital ، يجب أن يظهر إخراج وحدة التحكم "صافي رأس المال العامل هو: 2".'
|
||||
testString: 'assert(netWorkingCapital === 2, "Check the spelling of the two variables used in the netWorkingCapital calculation, the console output should show that "Net working capital is: 2".");'
|
||||
- text: يجب ألا تكون هناك حالات من متغيرات غير صحيحة في التعليمة البرمجية.
|
||||
testString: 'assert(!code.match(/recievables/g), "There should be no instances of mis-spelled variables in the code.");'
|
||||
- text: يجب الإعلان عن متغير <code>receivables</code> واستخدامه بشكل صحيح في الشفرة.
|
||||
testString: 'assert(code.match(/receivables/g).length == 2, "The <code>receivables</code> variable should be declared and used properly in the code.");'
|
||||
- text: يجب ألا تكون هناك حالات من متغيرات غير صحيحة في التعليمة البرمجية.
|
||||
testString: 'assert(!code.match(/payable;/g), "There should be no instances of mis-spelled variables in the code.");'
|
||||
- text: يجب الإعلان عن متغير <code>payables</code> واستخدامه بشكل صحيح في الشفرة.
|
||||
testString: 'assert(code.match(/payables/g).length == 2, "The <code>payables</code> variable should be declared and used properly in the code.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
let receivables = 10;
|
||||
let payables = 8;
|
||||
let netWorkingCapital = recievables - payable;
|
||||
console.log(`Net working capital is: ${netWorkingCapital}`);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@ -0,0 +1,52 @@
|
||||
---
|
||||
id: 587d7b84367417b2b2512b37
|
||||
title: Catch Mixed Usage of Single and Double Quotes
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: قبض على الاستخدام المختلط من أسعار مفردة ومزدوجة
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> تسمح جافا سكريبت باستخدام كل من الاقتباس الفردي ("") والمزدوج ("") لإعلان سلسلة. إن تحديد أي واحد يستخدم بشكل عام يعود إلى التفضيل الشخصي ، مع بعض الاستثناءات. وجود خيارين يكونان رائعين عند وجود سلسلة أو تقلصات أخرى. جزء من النص الموجود بين علامتي اقتباس ، ولكن عليك أن تكون حريصًا على عدم إغلاق السلسلة مبكرًا ، مما يؤدي إلى حدوث خطأ في بناء الجملة. في ما يلي بعض الأمثلة لخلط علامات التنصيص: <blockquote style=";text-align:right;direction:rtl"> // هذه صحيحة: <br> const grouchoContraction = "لقد أمضيت أمسية رائعة ، لكن هذا لم يكن كذلك."؛ <br> const quoteInString = "قال غروشو ماركس ذات مرة" اقتبسني قائلا: "لقد تم اقتباس أسئتي". <br> // هذا غير صحيح: <br> const uhOhGroucho = 'لقد أمضيت أمسية رائعة ، لكن هذا لم يكن كذلك.'؛ </blockquote> بالطبع ، لا بأس من استخدام نمط واحد فقط من علامات الاقتباس. يمكنك الهروب من علامات الاقتباس داخل السلسلة باستخدام حرف الهروب الخط المائل للخلف (\): <blockquote style=";text-align:right;direction:rtl"> // الاستخدام الصحيح لنفس الأسعار: <br> const allSameQuotes = 'لقد كان لي أمسية رائعة ، ولكن هذا لم يكن كذلك.'؛ </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> أصلح السلسلة بحيث تستخدم إما علامات اقتباس مختلفة لقيمة <code>href</code> ، أو تهرب منها. احتفظ بعلامات الاقتباس المزدوجة حول السلسلة بأكملها. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: 'يجب أن تحدد شفرتك علامات الاقتباس حول قيمة <code>href</code> "# Home" إما بتغييرها أو الهروب منها.'
|
||||
testString: 'assert(code.match(/<a href=\s*?("|\\")#Home\1\s*?>/g), "Your code should fix the quotes around the <code>href</code> value "#Home" by either changing or escaping them.");'
|
||||
- text: يجب أن تحتفظ شفرتك بالعلامات المزدوجة حول السلسلة بأكملها.
|
||||
testString: 'assert(code.match(/"<p>.*?<\/p>";/g), "Your code should keep the double quotes around the entire string.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
let innerHtml = "<p>Click here to <a href="#Home">return home</a></p>";
|
||||
console.log(innerHtml);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@ -0,0 +1,65 @@
|
||||
---
|
||||
id: 587d7b86367417b2b2512b3b
|
||||
title: Catch Off By One Errors When Using Indexing
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: القبض عن طريق واحدة من الأخطاء عند استخدام الفهرسة
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> <code>Off by one errors</code> (تسمى أحيانًا OBOE) عند محاولة استهداف فهرس معين لسلسلة أو صفيف (لتقسيم شريحة أو الوصول إليها) ، أو عند التكرار فوق مؤشراتها. تبدأ فهرسة جافا سكريبت في الصفر ، وليس واحدة ، مما يعني أن الفهرس الأخير يكون دائمًا أقل من طول العنصر. إذا حاولت الوصول إلى فهرس مساوٍ للطول ، فقد يلقي البرنامج خطأ مرجع "فهرسة خارج النطاق" أو يطبع <code>undefined</code> . عند استخدام سلسلة أو طرق صفيف تأخذ نطاقات الفهرس كوسيطة ، فإنها تساعد على قراءة الوثائق وفهم ما إذا كانت شاملة (العنصر الموجود في الفهرس المعين هو جزء مما تم إرجاعه) أم لا. في ما يلي بعض الأمثلة على أخطاء واحدة: <blockquote style=";text-align:right;direction:rtl"> let alphabet = "abcdefghijklmnopqrstuvwxyz"؛ <br> دعونا لين = alphabet.length. <br> لـ (let i = 0؛ i <= len؛ i ++) { <br> // حلقات واحدة عدة مرات في النهاية <br> console.log (الأبجدية [أنا])؛ <br> } <br> لـ (let j = 1؛ j <len؛ j ++) { <br> // يكرر مرات قليلة جدًا ويفتقد الحرف الأول في الفهرس 0 <br> console.log (الأبجدية [ي])؛ <br> } <br> لـ (let k = 0؛ k <len؛ k ++) { <br> // يوافق Goldilocks - وهذا هو الصحيح <br> console.log (الأبجدية [ك])؛ <br> } </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> إصلاح أخطاء الفهرسة في الدالة التالية بحيث يتم طباعة كافة الأرقام من 1 إلى 5 إلى وحدة التحكم. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن تقوم التعليمات البرمجية بتعيين الشرط الأولي للحلقة بحيث يبدأ في الفهرس الأول.
|
||||
testString: 'assert(code.match(/i\s*?=\s*?0\s*?;/g).length == 1, "Your code should set the initial condition of the loop so it starts at the first index.");'
|
||||
- text: يجب أن تقوم التعليمات البرمجية الخاصة بك بإصلاح الشرط الأولي للحلقة بحيث يبدأ الفهرس عند 0.
|
||||
testString: 'assert(!code.match(/i\s?=\s*?1\s*?;/g), "Your code should fix the initial condition of the loop so that the index starts at 0.");'
|
||||
- text: يجب أن تحدد شفرتك حالة المحطة الطرفية للحلقة بحيث تتوقف عند الفهرس الأخير.
|
||||
testString: 'assert(code.match(/i\s*?<\s*?len\s*?;/g).length == 1, "Your code should set the terminal condition of the loop so it stops at the last index.");'
|
||||
- text: يجب أن تقوم تعليماتك البرمجية بإصلاح حالة الحلقة الطرفية بحيث تتوقف عند 1 قبل الطول.
|
||||
testString: 'assert(!code.match(/i\s*?<=\s*?len;/g), "Your code should fix the terminal condition of the loop so that it stops at 1 before the length.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function countToFive() {
|
||||
let firstFive = "12345";
|
||||
let len = firstFive.length;
|
||||
// Fix the line below
|
||||
for (let i = 1; i <= len; i++) {
|
||||
// Do not alter code below this line
|
||||
console.log(firstFive[i]);
|
||||
}
|
||||
}
|
||||
|
||||
countToFive();
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@ -0,0 +1,53 @@
|
||||
---
|
||||
id: 587d7b84367417b2b2512b36
|
||||
title: 'Catch Unclosed Parentheses, Brackets, Braces and Quotes'
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: قبض على الأقواس غير المغلقة ، بين قوسين ، الأقواس والاقتباسات
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> هناك خطأ آخر في بناء الجملة يجب أن يكون على دراية بأن جميع أقواس الفتح ، الأقواس ، الأقواس المعقوفة ، وعلامات الاقتباس لها زوج إغلاق. يؤدي نسيان قطعة إلى الحدوث عند تحرير الشفرة الحالية وإدراج عناصر تحتوي على أحد أنواع الزوج. أيضًا ، توخ الحذر عند تضمين كتل التعليمات البرمجية في الآخرين ، مثل إضافة وظيفة رد اتصال كوسيطة إلى طريقة ما. هناك طريقة واحدة لتجنب هذا الخطأ بمجرد كتابة الحرف الافتتاحي ، وتضمين على الفور تطابق الإغلاق ، ثم حرك المؤشر للخلف بينهما واستمر في الترميز. لحسن الحظ ، فإن معظم برامج تحرير الشفرة الحديثة تولد النصف الثاني من الزوج تلقائيًا. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> أصلح خطأ الزوج في الشفرة. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن تعمل شفرتك على إصلاح الجزء المفقود من المصفوفة.
|
||||
testString: 'assert(code.match(/myArray\s*?=\s*?\[\s*?1\s*?,\s*?2\s*?,\s*?3\s*?\];/g), "Your code should fix the missing piece of the array.");'
|
||||
- text: 'يجب أن تقوم التعليمات البرمجية الخاصة بك بإصلاح الجزء المفقود من طريقة <code>.reduce()</code> . يجب أن يظهر إخراج وحدة التحكم أن "مجموع قيم الصفيف: 6".'
|
||||
testString: 'assert(arraySum === 6, "Your code should fix the missing piece of the <code>.reduce()</code> method. The console output should show that "Sum of array values is: 6".");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
let myArray = [1, 2, 3;
|
||||
let arraySum = myArray.reduce((previous, current => previous + current);
|
||||
console.log(`Sum of array values is: ${arraySum}`);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@ -0,0 +1,61 @@
|
||||
---
|
||||
id: 587d7b85367417b2b2512b38
|
||||
title: Catch Use of Assignment Operator Instead of Equality Operator
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: قبض على استخدام مشغل التعيين بدلا من مشغل المساواة
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> تعتمد البرامج المتفرعة ، أي البرامج التي تقوم بأشياء مختلفة إذا تم استيفاء شروط معينة ، على <code>if</code> <code>else if</code> <code>else</code> عبارات أخرى في جافا سكريبت أو غير ذلك أو <code>else</code> . تأخذ الحالة أحيانًا شكل اختبار ما إذا كانت النتيجة مساوية لقيمة ما. يتم نطق هذا المنطق (باللغة الإنجليزية ، على الأقل) على أنه "إذا كان x يساوي y ، ثم ..." والذي يمكن أن يترجم حرفيًا إلى تعليمة برمجية باستخدام عامل التشغيل أو <code>=</code> أو عامل التشغيل. هذا يؤدي إلى تدفق التحكم غير متوقع في البرنامج الخاص بك. كما تم تغطيته في التحديات السابقة ، يقوم عامل التعيين ( <code>=</code> ) في JavaScript بتعيين قيمة لاسم متغير. و <code>==</code> و <code>===</code> عوامل التحقق من المساواة (اختبار <code>===</code> الثلاثي من أجل المساواة الصارمة ، مما يعني أن القيمة والنوع هما نفس الشيء). يعيّن الرمز أدناه <code>x</code> إلى 2 ، والتي يتم تقييمها على أنها <code>true</code> . تقريبًا كل قيمة من تلقاء نفسها في جافا سكريبت يتم تقييمها إلى <code>true</code> ، باستثناء ما يُعرف بالقيم "الفالية": <code>false</code> ، و <code>0</code> ، و <code>""</code> (سلسلة فارغة) ، و <code>NaN</code> ، و <code>undefined</code> ، و <code>null</code> . <blockquote style=";text-align:right;direction:rtl"> دع x = 1؛ <br> دعنا y = 2؛ <br> إذا (x = y) { <br> // سيتم تشغيل هذا الكود لأية قيمة لـ y (ما لم يتم تعيين y في الأصل كالفلا) <br> } آخر { <br> // كتلة الكود هذا هو ما يجب تشغيله (لكن لن) في هذا المثال <br> } </blockquote></section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> أصلح الشرط بحيث يقوم البرنامج بتشغيل الفرع الصحيح ، ويتم تعيين القيمة المناسبة <code>result</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن تحدد شفرتك الشرط حتى تتحقق من المساواة ، بدلاً من استخدام الواجب.
|
||||
testString: 'assert(result == "Not equal!", "Your code should fix the condition so it checks for equality, instead of using assignment.");'
|
||||
- text: يمكن أن تستخدم الحالة إما <code>==</code> أو <code>===</code> لاختبار المساواة.
|
||||
testString: 'assert(code.match(/x\s*?===?\s*?y/g), "The condition can use either <code>==</code> or <code>===</code> to test for equality.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
let x = 7;
|
||||
let y = 9;
|
||||
let result = "to come";
|
||||
|
||||
if(x = y) {
|
||||
result = "Equal!";
|
||||
} else {
|
||||
result = "Not equal!";
|
||||
}
|
||||
|
||||
console.log(result);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@ -0,0 +1,55 @@
|
||||
---
|
||||
id: 587d7b86367417b2b2512b3d
|
||||
title: Prevent Infinite Loops with a Valid Terminal Condition
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: منع حلقات لا نهائية مع شرط محطة صالح
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> الموضوع الأخير هو حلقة اللانهائي اللعين. الحلقات هي أدوات رائعة عندما تحتاج إلى برنامج لتشغيل كتلة التعليمات البرمجية لعدد معين من المرات أو حتى يتم استيفاء الشرط ، ولكنها تحتاج إلى حالة طرفية تنهي التكرار. من المحتمل أن تؤدي الحلقات اللانهائية إلى تجميد المتصفح أو تعطله ، وتتسبب في حدوث فشل في تنفيذ البرنامج العام ، وهو ما لا يريده أحد. كان هناك مثال حلقة لا نهائية في مقدمة هذا القسم - ليس لديها أي شرط المحطة للخروج من <code>while</code> حلقة داخل <code>loopy()</code> . لا ندعو هذه الوظيفة! <blockquote style=";text-align:right;direction:rtl"> function loopy () { <br> احيانا صحيح) { <br> console.log ("Hello، world!")؛ <br> } <br> } </blockquote> إنها وظيفة المبرمج لضمان أن يتم الوصول في نهاية المطاف إلى حالة المحطة الطرفية ، التي تخبر البرنامج عند الخروج من شفرة التكرار. خطأ واحد هو زيادة أو إنقاص متغير عداد في الاتجاه الخاطئ من حالة المحطة الطرفية. واحد آخر هو بطريق الخطأ إعادة تعيين عداد أو فهرس متغير داخل رمز التكرار ، بدلاً من زيادة أو إنقاصه. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> تحتوي الدالة <code>myFunc()</code> على حلقة لانهائية نظرًا لأن حالة المحطة الطرفية <code>i != 4</code> لن يتم تقييمها أبداً إلى <code>false</code> (وكسر الحلقات) - سوف <code>i</code> بزيادة 2 لكل مسار ، والقفز مباشرة فوق 4 لأن <code>i</code> هو أمر غريب للبدء. إصلاح عامل مقارنة في حالة محطة حتى الحلقة يعمل فقط ل <code>i</code> أقل من أو يساوي 4. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: التعليمات البرمجية يجب أن تتغير عامل مقارنة في حالة الطرفية (الجزء الأوسط) من <code>for</code> حلقة.
|
||||
testString: 'assert(code.match(/i\s*?<=\s*?4;/g).length == 1, "Your code should change the comparison operator in the terminal condition (the middle part) of the <code>for</code> loop.");'
|
||||
- text: يجب أن تقوم التعليمات البرمجية الخاصة بك بإصلاح عامل المقارنة في حالة طرفية الحلقة.
|
||||
testString: 'assert(!code.match(/i\s*?!=\s*?4;/g), "Your code should fix the comparison operator in the terminal condition of the loop.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function myFunc() {
|
||||
for (let i = 1; i != 4; i += 2) {
|
||||
console.log("Still going!");
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@ -0,0 +1,62 @@
|
||||
---
|
||||
id: 587d7b83367417b2b2512b37
|
||||
title: Understanding the Differences between the freeCodeCamp and Browser Console
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: فهم الاختلافات بين freeCodeCamp و Browser Console
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> قد تكون لاحظت أن بعض تحديات JavaScript freeCodeCamp تتضمن وحدة التحكم الخاصة بهم. تعمل وحدة التحكم هذه بشكل مختلف قليلاً عن وحدة تحكم المستعرض التي استخدمتها في التحدي الأخير. يتمثل التحدي التالي في إبراز بعض الاختلافات بين وحدة التحكم freeCodeCamp ووحدة تحكم المستعرض. أولا ، وحدة تحكم المتصفح. عندما تقوم بتحميل وتشغيل ملف جافا سكريبت عادي في متصفحك ، ستقوم عبارات <code>console.log()</code> بطباعة ما تطلبه بالضبط للطباعة إلى وحدة تحكم المستعرض بالضبط عدد المرات التي طلبتها. في محرر النص داخل المتصفح ، تكون العملية مختلفة قليلاً ويمكن أن تكون مربكة في البداية. تشغيل القيم التي تم تمريرها إلى <code>console.log()</code> في كتلة محرر النص ، كل مجموعة من الاختبارات بالإضافة إلى وقت آخر لأية استدعاءات دالة موجودة في التعليمات البرمجية. وهذا يفسح المجال لبعض السلوكيات المثيرة للاهتمام وقد يقوم برحلتك في البداية ، لأن القيمة المسجلة التي تتوقع أن ترى مرة واحدة فقط قد تطبع مرات أكثر اعتمادًا على عدد الاختبارات والقيم التي يتم تمريرها إلى تلك الاختبارات. إذا كنت ترغب في رؤية مخرجاتك الفردية فقط ولا داعي للقلق بشأن تشغيل الدورات الاختبارية ، فيمكنك استخدام <code>console.clear()</code> . </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> استخدم <code>console.log()</code> لطباعة المتغيرات في التعليمة البرمجية في المكان المحدد. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: استخدم <code>console.log()</code> لطباعة <code>outputTwo</code> المتغير. في وحدة تحكم المتصفح لديك ، يجب أن تطبع قيمة المتغير مرتين.
|
||||
testString: 'assert(code.match(/console\.log\(outputTwo\)/g), "Use <code>console.log()</code> to print the <code>outputTwo</code> variable. In your Browser Console this should print out the value of the variable two times.");'
|
||||
- text: استخدم <code>console.log()</code> لطباعة متغير <code>outputOne</code> .
|
||||
testString: 'assert(code.match(/console\.log\(outputOne\)/g), "Use <code>console.log()</code> to print the <code>outputOne</code> variable.");'
|
||||
- text: استخدم <code>console.clear()</code> لتعديل الإخراج الخاص بك بحيث يتم إخراج <code>outputOne</code> فقط مرة واحدة.
|
||||
testString: 'assert(code.match(/^(\s*console.clear\(\);?\s*)$/gm), "Use <code>console.clear()</code> to modify your output so that <code>outputOne</code> variable only outputs once.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
// Open your browser console
|
||||
let outputTwo = "This will print to the browser console 2 times";
|
||||
// Use console.log() to print the outputTwo variable
|
||||
|
||||
|
||||
let outputOne = "Try to get this to log only once to the browser console";
|
||||
// Use console.clear() in the next line to print the outputOne only once
|
||||
|
||||
|
||||
// Use console.log() to print the outputOne variable
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@ -0,0 +1,71 @@
|
||||
---
|
||||
id: 587d7b86367417b2b2512b3c
|
||||
title: Use Caution When Reinitializing Variables Inside a Loop
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: استخدام الحذر عند Reinitializing متغيرات داخل حلقة
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> في بعض الأحيان يكون من الضروري حفظ المعلومات أو زيادة العدادات أو إعادة تعيين المتغيرات داخل حلقة. وتتمثل إحدى المشكلات المحتملة في ضرورة إعادة تهيئة المتغيرات ، وليس العكس ، أو العكس. هذا أمر خطير بشكل خاص إذا قمت بإعادة تعيين المتغير الذي يتم استخدامه لحالة المحطة عن طريق الخطأ ، مما تسبب في حلقة لا نهائية. يمكن لقيم الطباعة المتغيرة مع كل دورة من الحلقات باستخدام <code>console.log()</code> الكشف عن سلوك عربات التي تجرها الدواب المتعلقة بإعادة الضبط أو الفشل في إعادة تعيين متغير. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> من المفترض أن تقوم الدالة التالية بإنشاء مصفوفة ثنائية الأبعاد مع صفوف <code>m</code> وأعمدة <code>n</code> من الأصفار. لسوء الحظ ، فإنه لا ينتج الإخراج المتوقع لأنه لا تتم إعادة تهيئة متغير <code>row</code> (إعادة تعيين صفيف فارغ) في الحلقة الخارجية. قم بإصلاح الكود بحيث يقوم بإرجاع صفيف 3x2 الصحيح من الأصفار ، والذي يشبه <code>[[0, 0], [0, 0], [0, 0]]</code> . </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن يقوم <code>matrix</code> بتعيين متغير <code>matrix</code> على صفيف يحتوي على 3 صفوف من عمودين من الأصفار لكل منهما.
|
||||
testString: 'assert(JSON.stringify(matrix) == "[[0,0],[0,0],[0,0]]", "Your code should set the <code>matrix</code> variable to an array holding 3 rows of 2 columns of zeroes each.");'
|
||||
- text: يجب أن يكون متغير <code>matrix</code> 3 صفوف.
|
||||
testString: 'assert(matrix.length == 3, "The <code>matrix</code> variable should have 3 rows.");'
|
||||
- text: يجب أن يحتوي متغير <code>matrix</code> على عمودين في كل صف.
|
||||
testString: 'assert(matrix[0].length == 2 && matrix[1].length === 2 && matrix[2].length === 2, "The <code>matrix</code> variable should have 2 columns in each row.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
function zeroArray(m, n) {
|
||||
// Creates a 2-D array with m rows and n columns of zeroes
|
||||
let newArray = [];
|
||||
let row = [];
|
||||
for (let i = 0; i < m; i++) {
|
||||
// Adds the m-th row into newArray
|
||||
|
||||
for (let j = 0; j < n; j++) {
|
||||
// Pushes n zeroes into the current row to create the columns
|
||||
row.push(0);
|
||||
}
|
||||
// Pushes the current row, which now has n zeroes in it, to the array
|
||||
newArray.push(row);
|
||||
}
|
||||
return newArray;
|
||||
}
|
||||
|
||||
let matrix = zeroArray(3, 2);
|
||||
console.log(matrix);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@ -0,0 +1,56 @@
|
||||
---
|
||||
id: 587d7b83367417b2b2512b33
|
||||
title: Use the JavaScript Console to Check the Value of a Variable
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: استخدم وحدة تحكم جافا سكريبت للتحقق من قيمة المتغير
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يحتوي كل من Chrome و Firefox على وحدات تحكم جافا سكريبت ممتازة ، تُعرف أيضًا باسم DevTools ، لتصحيح أخطاء جافا سكريبت. يمكنك العثور على أدوات مطوري البرامج في قائمة Chrome أو وحدة تحكم الويب في قائمة FireFox. إذا كنت تستخدم متصفحًا مختلفًا أو هاتفًا جوالًا ، فنحن نوصي بشدة بالتبديل إلى مكتبي Firefox أو Chrome. من المحتمل أن تكون طريقة <code>console.log()</code> ، التي "تطبع" مخرجات ما داخل أقواسها إلى وحدة التحكم ، أداة التصحيح الأكثر فائدة. يمكن وضعه في النقاط الاستراتيجية في التعليمات البرمجية الخاصة بك تظهر لك القيم المتوسطة للمتغيرات. من الجيد أن يكون لديك فكرة عن ما يجب أن يكون عليه المخرج قبل النظر إلى ما هو عليه. وجود نقاط تحقق لرؤية حالة الحسابات الخاصة بك في جميع أنحاء التعليمات البرمجية الخاصة بك سيساعد على تضييق نطاق المشكلة. في ما يلي مثال لطباعة "Hello world!" إلى وحدة التحكم: <code>console.log('Hello world!');</code> </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> استخدم الأسلوب <code>console.log()</code> لطباعة قيمة المتغير <code>a</code> المكان الذي تمت الإشارة إليه في التعليمة البرمجية. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن تستخدم التعليمات البرمجية الخاصة بك <code>console.log()</code> للتحقق من قيمة المتغير <code>a</code> .
|
||||
testString: 'assert(code.match(/console\.log\(a\)/g), "Your code should use <code>console.log()</code> to check the value of the variable <code>a</code>.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
let a = 5;
|
||||
let b = 1;
|
||||
a++;
|
||||
// Add your code below this line
|
||||
|
||||
|
||||
let sumAB = a + b;
|
||||
console.log(sumAB);
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
@ -0,0 +1,56 @@
|
||||
---
|
||||
id: 587d7b84367417b2b2512b34
|
||||
title: Use typeof to Check the Type of a Variable
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
localeTitle: استخدم typeof للتحقق من نوع المتغير
|
||||
---
|
||||
|
||||
## Description
|
||||
<section id="description"> يمكنك استخدام <code>typeof</code> للتحقق من بنية البيانات أو نوع المتغير. هذا مفيد في تصحيح الأخطاء عند العمل مع أنواع بيانات متعددة. إذا كنت تعتقد أنك تضيف رقمين ، لكن أحدهما عبارة عن سلسلة ، فيمكن أن تكون النتائج غير متوقعة. يمكن أن تكمن أخطاء الكتابة في العمليات الحسابية أو المكالمات الوظيفية. كن حذرًا خصوصًا عند الوصول إلى البيانات الخارجية والعمل بها في شكل كائن ترميز كائنات جافا سكريبت (JSON). فيما يلي بعض الأمثلة باستخدام <code>typeof</code> : <blockquote style=";text-align:right;direction:rtl"> console.log (typeof "") ؛ // مخرجات "سلسلة" <br> console.log (typeof 0)؛ // outputs "number" <br> console.log (typeof [])؛ // outputs "object" <br> console.log (typeof {})؛ // outputs "object" </blockquote> يتعرف JavaScript على ستة أنواع من البيانات البدائية (غير القابلة للتغيير): <code>Boolean</code> و <code>Null</code> و <code>Undefined</code> و <code>Number</code> و <code>String</code> و <code>Symbol</code> (جديد مع ES6) ونوع واحد للعناصر القابلة للتغيير: <code>Object</code> . لاحظ أنه في JavaScript ، تعد المصفوفات نوعًا من الكائنات تقنيًا. </section>
|
||||
|
||||
## Instructions
|
||||
<section id="instructions"> إضافة جهازي <code>console.log()</code> للتحقق من <code>typeof</code> كل من المتغيرات <code>seven</code> <code>three</code> في التعليمات البرمجية. </section>
|
||||
|
||||
## Tests
|
||||
<section id='tests'>
|
||||
|
||||
```yml
|
||||
tests:
|
||||
- text: يجب أن تستخدم التعليمات البرمجية الخاصة بك <code>typeof</code> في جهازي <code>console.log()</code> للتحقق من نوع المتغيرات.
|
||||
testString: 'assert(code.match(/console\.log\(typeof[\( ].*\)?\)/g).length == 2, "Your code should use <code>typeof</code> in two <code>console.log()</code> statements to check the type of the variables.");'
|
||||
- text: يجب أن تستخدم التعليمات البرمجية الخاصة بك <code>typeof</code> للتحقق من نوع المتغير <code>seven</code> .
|
||||
testString: 'assert(code.match(/typeof[\( ]seven\)?/g), "Your code should use <code>typeof</code> to check the type of the variable <code>seven</code>.");'
|
||||
- text: يجب أن تستخدم التعليمات البرمجية الخاصة بك <code>typeof</code> للتحقق من نوع المتغير <code>three</code> .
|
||||
testString: 'assert(code.match(/typeof[\( ]three\)?/g), "Your code should use <code>typeof</code> to check the type of the variable <code>three</code>.");'
|
||||
|
||||
```
|
||||
|
||||
</section>
|
||||
|
||||
## Challenge Seed
|
||||
<section id='challengeSeed'>
|
||||
|
||||
<div id='js-seed'>
|
||||
|
||||
```js
|
||||
let seven = 7;
|
||||
let three = "3";
|
||||
console.log(seven + three);
|
||||
// Add your code below this line
|
||||
|
||||
```
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</section>
|
||||
|
||||
## Solution
|
||||
<section id='solution'>
|
||||
|
||||
```js
|
||||
// solution required
|
||||
```
|
||||
</section>
|
Reference in New Issue
Block a user