Add languages Russian, Arabic, Chinese, Portuguese (#18305)

This commit is contained in:
Beau Carnes
2018-10-10 18:03:03 -04:00
committed by mrugesh mohapatra
parent 09d3eca712
commit 2ca3a2093f
5517 changed files with 371466 additions and 5 deletions

View File

@ -0,0 +1,74 @@
---
id: a77dbc43c33f39daa4429b4f
title: Boo who
isRequired: true
challengeType: 5
videoUrl: ''
localeTitle: بو من
---
## Description
<section id="description"> تحقق مما إذا كانت القيمة مصنفة على أنها بدائية منطقية. إرجاع صح أو خطأ. الأجناس البولية هي صحيحة وكاذبة. تذكر استخدام <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> إذا واجهتك مشكلة. حاول إقران البرنامج. اكتب الكود الخاص بك. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>booWho(true)</code> يجب أن <code>booWho(true)</code> true.
testString: 'assert.strictEqual(booWho(true), true, "<code>booWho(true)</code> should return true.");'
- text: <code>booWho(false)</code> يجب أن يعود صحيحًا.
testString: 'assert.strictEqual(booWho(false), true, "<code>booWho(false)</code> should return true.");'
- text: '<code>booWho([1, 2, 3])</code> يجب أن تعود خاطئة.'
testString: 'assert.strictEqual(booWho([1, 2, 3]), false, "<code>booWho([1, 2, 3])</code> should return false.");'
- text: 'يجب أن تعود <code>booWho([].slice)</code> كاذبة.'
testString: 'assert.strictEqual(booWho([].slice), false, "<code>booWho([].slice)</code> should return false.");'
- text: ''
testString: 'assert.strictEqual(booWho({ "a": 1 }), false, "<code>booWho({ "a": 1 })</code> should return false.");'
- text: يجب أن يقوم <code>booWho(1)</code> بإرجاع false.
testString: 'assert.strictEqual(booWho(1), false, "<code>booWho(1)</code> should return false.");'
- text: يجب أن تعود <code>booWho(NaN)</code> كاذبة.
testString: 'assert.strictEqual(booWho(NaN), false, "<code>booWho(NaN)</code> should return false.");'
- text: <code>booWho(&quot;a&quot;)</code> بإرجاع false.
testString: 'assert.strictEqual(booWho("a"), false, "<code>booWho("a")</code> should return false.");'
- text: <code>booWho(&quot;true&quot;)</code> بإرجاع false.
testString: 'assert.strictEqual(booWho("true"), false, "<code>booWho("true")</code> should return false.");'
- text: <code>booWho(&quot;false&quot;)</code> بإرجاع false.
testString: 'assert.strictEqual(booWho("false"), false, "<code>booWho("false")</code> should return false.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function booWho(bool) {
// What is the new fad diet for ghost developers? The Boolean.
return bool;
}
booWho(null);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,68 @@
---
id: a9bd25c716030ec90084d8a1
title: Chunky Monkey
isRequired: true
challengeType: 5
videoUrl: ''
localeTitle: قرد مكتنز
---
## Description
<section id="description"> اكتب دالة تقسم صفيف (أول وسيطة) إلى مجموعات طول <code>size</code> (وسيطة ثانية) وتقوم بإرجاعها كمصفوفة ثنائية الأبعاد. تذكر استخدام <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> إذا واجهتك مشكلة. اكتب الكود الخاص بك. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>chunkArrayInGroups([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;, &quot;d&quot;], 2)</code> يجب أن ترجع <code>[[&quot;a&quot;, &quot;b&quot;], [&quot;c&quot;, &quot;d&quot;]]</code> .'
testString: 'assert.deepEqual(chunkArrayInGroups(["a", "b", "c", "d"], 2), [["a", "b"], ["c", "d"]], "<code>chunkArrayInGroups(["a", "b", "c", "d"], 2)</code> should return <code>[["a", "b"], ["c", "d"]]</code>.");'
- text: '<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3)</code> يجب أن تعود <code>[[0, 1, 2], [3, 4, 5]]</code> .'
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3), [[0, 1, 2], [3, 4, 5]], "<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 3)</code> should return <code>[[0, 1, 2], [3, 4, 5]]</code>.");'
- text: '<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2)</code> يجب أن ترجع <code>[[0, 1], [2, 3], [4, 5]]</code> .'
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2), [[0, 1], [2, 3], [4, 5]], "<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 2)</code> should return <code>[[0, 1], [2, 3], [4, 5]]</code>.");'
- text: '<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4)</code> return <code>[[0, 1, 2, 3], [4, 5]]</code> .'
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4), [[0, 1, 2, 3], [4, 5]], "<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5], 4)</code> should return <code>[[0, 1, 2, 3], [4, 5]]</code>.");'
- text: '<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3)</code> يجب أن تعود <code>[[0, 1, 2], [3, 4, 5], [6]]</code> .'
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3), [[0, 1, 2], [3, 4, 5], [6]], "<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6], 3)</code> should return <code>[[0, 1, 2], [3, 4, 5], [6]]</code>.");'
- text: '<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4)</code> يجب أن تعود <code>[[0, 1, 2, 3], [4, 5, 6, 7], [8]]</code> .'
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4), [[0, 1, 2, 3], [4, 5, 6, 7], [8]], "<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 4)</code> should return <code>[[0, 1, 2, 3], [4, 5, 6, 7], [8]]</code>.");'
- text: '<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2)</code> يجب أن تعود <code>[[0, 1], [2, 3], [4, 5], [6, 7], [8]]</code> .'
testString: 'assert.deepEqual(chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2), [[0, 1], [2, 3], [4, 5], [6, 7], [8]], "<code>chunkArrayInGroups([0, 1, 2, 3, 4, 5, 6, 7, 8], 2)</code> should return <code>[[0, 1], [2, 3], [4, 5], [6, 7], [8]]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function chunkArrayInGroups(arr, size) {
// Break it up.
return arr;
}
chunkArrayInGroups(["a", "b", "c", "d"], 2);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,77 @@
---
id: acda2fb1324d9b0fa741e6b5
title: Confirm the Ending
isRequired: true
challengeType: 5
videoUrl: ''
localeTitle: تأكيد الانتهاء
---
## Description
<section id="description"> تحقق مما إذا كانت سلسلة (الوسيطة الأولى ، <code>str</code> ) تنتهي بسلسلة الهدف المحددة (الوسيطة الثانية ، <code>target</code> ). <em>يمكن</em> حل هذا التحدي باستخدام طريقة <code>.endsWith()</code> ، التي تم تقديمها في ES2015. ولكن لغرض هذا التحدي ، نود منك استخدام إحدى طرق السلسلة الفرعية JavaScript بدلاً من ذلك. تذكر استخدام <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> إذا واجهتك مشكلة. اكتب الكود الخاص بك. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>confirmEnding(&quot;Bastian&quot;, &quot;n&quot;)</code> يجب أن ترجع true.'
testString: 'assert(confirmEnding("Bastian", "n") === true, "<code>confirmEnding("Bastian", "n")</code> should return true.");'
- text: '<code>confirmEnding(&quot;Congratulation&quot;, &quot;on&quot;)</code> يجب أن تعود إلى true.'
testString: 'assert(confirmEnding("Congratulation", "on") === true, "<code>confirmEnding("Congratulation", "on")</code> should return true.");'
- text: '<code>confirmEnding(&quot;Connor&quot;, &quot;n&quot;)</code> يجب أن ترجع false.'
testString: 'assert(confirmEnding("Connor", "n") === false, "<code>confirmEnding("Connor", "n")</code> should return false.");'
- text: '<code>confirmEnding(&quot;Walking on water and developing software from a specification are easy if both are frozen&quot;, &quot;specification&quot;)</code> يجب أن تعود خاطئة.'
testString: 'assert(confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification") === false, "<code>confirmEnding("Walking on water and developing software from a specification are easy if both are frozen"&#44; "specification"&#41;</code> should return false.");'
- text: '<code>confirmEnding(&quot;He has to give me a new name&quot;, &quot;name&quot;)</code> يجب أن <code>confirmEnding(&quot;He has to give me a new name&quot;, &quot;name&quot;)</code> .'
testString: 'assert(confirmEnding("He has to give me a new name", "name") === true, "<code>confirmEnding("He has to give me a new name", "name")</code> should return true.");'
- text: '<code>confirmEnding(&quot;Open sesame&quot;, &quot;same&quot;)</code> يجب أن ترجع true.'
testString: 'assert(confirmEnding("Open sesame", "same") === true, "<code>confirmEnding("Open sesame", "same")</code> should return true.");'
- text: '<code>confirmEnding(&quot;Open sesame&quot;, &quot;pen&quot;)</code> يجب أن يقوم بإرجاع false.'
testString: 'assert(confirmEnding("Open sesame", "pen") === false, "<code>confirmEnding("Open sesame", "pen")</code> should return false.");'
- text: '<code>confirmEnding(&quot;Open sesame&quot;, &quot;game&quot;)</code> يجب أن ترجع false.'
testString: 'assert(confirmEnding("Open sesame", "game") === false, "<code>confirmEnding("Open sesame", "game")</code> should return false.");'
- text: '<code>confirmEnding(&quot;If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing&quot;, &quot;mountain&quot;)</code> يجب أن تعود كاذبة.'
testString: 'assert(confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain") === false, "<code>confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain")</code> should return false.");'
- text: '<code>confirmEnding(&quot;Abstraction&quot;, &quot;action&quot;)</code> يجب أن <code>confirmEnding(&quot;Abstraction&quot;, &quot;action&quot;)</code> true.'
testString: 'assert(confirmEnding("Abstraction", "action") === true, "<code>confirmEnding("Abstraction", "action")</code> should return true.");'
- text: لا تستخدم الأسلوب <code>.endsWith()</code> لحل التحدي.
testString: 'assert(!(/\.endsWith\(.*?\)\s*?;?/.test(code)) && !(/\["endsWith"\]/.test(code)), "Do not use the built-in method <code>.endsWith()</code> to solve the challenge.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
return str;
}
confirmEnding("Bastian", "n");
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,66 @@
---
id: 56533eb9ac21ba0edf2244b3
title: Convert Celsius to Fahrenheit
challengeType: 1
isRequired: true
videoUrl: ''
localeTitle: تحويل مئوية إلى فهرنهايت
---
## Description
<section id="description"> الخوارزمية للتحويل من درجة مئوية إلى فهرنهايت هي درجة الحرارة في المرات المئوي <code>9/5</code> ، زائد <code>32</code> . يتم منحك درجة <code>celsius</code> متغيرة تمثل درجة الحرارة بالدرجة المئوية. استخدم المتغير <code>fahrenheit</code> تم تحديده بالفعل وقم بتعيينه درجة حرارة فهرنهايت مكافئة لدرجة حرارة مئوية معينة. استخدم الخوارزمية المذكورة أعلاه للمساعدة في تحويل درجة الحرارة مئوية إلى فهرنهايت. لا تقلق كثيراً بشأن بيانات الوظيفة والعودة حيث سيتم تغطيتها في التحديات المستقبلية. في الوقت الحالي ، استخدم فقط المشغلين الذين تعلموهم بالفعل. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن يقوم <code>convertToF(0)</code> بإرجاع رقم
testString: 'assert(typeof convertToF(0) === "number", "<code>convertToF(0)</code> should return a number");'
- text: يجب أن تقوم <code>convertToF(-30)</code> بإرجاع قيمة <code>-22</code>
testString: 'assert(convertToF(-30) === -22, "<code>convertToF(-30)</code> should return a value of <code>-22</code>");'
- text: يجب أن تقوم <code>convertToF(-10)</code> بإرجاع قيمة <code>14</code>
testString: 'assert(convertToF(-10) === 14, "<code>convertToF(-10)</code> should return a value of <code>14</code>");'
- text: يجب أن تقوم <code>convertToF(0)</code> بإرجاع قيمة <code>32</code>
testString: 'assert(convertToF(0) === 32, "<code>convertToF(0)</code> should return a value of <code>32</code>");'
- text: يجب أن تقوم <code>convertToF(20)</code> بإرجاع قيمة <code>68</code>
testString: 'assert(convertToF(20) === 68, "<code>convertToF(20)</code> should return a value of <code>68</code>");'
- text: يجب أن تقوم <code>convertToF(30)</code> بإرجاع قيمة <code>86</code>
testString: 'assert(convertToF(30) === 86, "<code>convertToF(30)</code> should return a value of <code>86</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function convertToF(celsius) {
let fahrenheit;
return fahrenheit;
}
convertToF(30);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,63 @@
---
id: a302f7aae1aa3152a5b413bc
title: Factorialize a Number
isRequired: true
challengeType: 5
videoUrl: ''
localeTitle: Factorialize عدد
---
## Description
<section id="description"> عودة المضروب من عدد صحيح المقدمة. إذا تم تمثيل العدد الصحيح بالحرف n ، فإن العامل الحاسوبي هو نتاج جميع الأعداد الصحيحة الموجبة أقل من أو يساوي n. غالبًا ما يتم تمثيل العوامل بعبارة الاختزال <code>n!</code> على سبيل المثال: <code>5! = 1 * 2 * 3 * 4 * 5 = 120</code> فقط تزويد الأعداد الصحيحة التي تزيد عن أو تساوي الصفر بالوظيفة. تذكر استخدام <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> إذا واجهتك مشكلة. اكتب الكود الخاص بك. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن يعيد <code>factorialize(5)</code> رقمًا.
testString: 'assert(typeof factorialize(5) === "number", "<code>factorialize(5)</code> should return a number.");'
- text: يجب أن يعيد <code>factorialize(5)</code> 120.
testString: 'assert(factorialize(5) === 120, "<code>factorialize(5)</code> should return 120.");'
- text: يجب أن يعيد التجهيز <code>factorialize(10)</code> 3628800.
testString: 'assert(factorialize(10) === 3628800, "<code>factorialize(10)</code> should return 3628800.");'
- text: يجب أن تعيد إنتاجية <code>factorialize(20)</code> 2432902008176640000.
testString: 'assert(factorialize(20) === 2432902008176640000, "<code>factorialize(20)</code> should return 2432902008176640000.");'
- text: يجب أن يعيد <code>factorialize(0)</code> 1.
testString: 'assert(factorialize(0) === 1, "<code>factorialize(0)</code> should return 1.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function factorialize(num) {
return num;
}
factorialize(5);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,62 @@
---
id: adf08ec01beb4f99fc7a68f2
title: Falsy Bouncer
isRequired: true
challengeType: 5
videoUrl: ''
localeTitle: فلسى الحارس
---
## Description
<section id="description"> قم بإزالة كافة قيم الفالسة من صفيف. تكون قيم Falsy في JavaScript <code>false</code> و <code>null</code> و <code>0</code> و <code>&quot;&quot;</code> و <code>undefined</code> و <code>NaN</code> . تلميح: حاول تحويل كل قيمة إلى قيمة منطقية. تذكر استخدام <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> إذا واجهتك مشكلة. اكتب الكود الخاص بك. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>bouncer([7, &quot;ate&quot;, &quot;&quot;, false, 9])</code> يجب أن يعود <code>[7, &quot;ate&quot;, 9]</code> .'
testString: 'assert.deepEqual(bouncer([7, "ate", "", false, 9]), [7, "ate", 9], "<code>bouncer([7, "ate", "", false, 9])</code> should return <code>[7, "ate", 9]</code>.");'
- text: 'يجب أن تعود <code>bouncer([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;])</code> <code>[&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]</code> .'
testString: 'assert.deepEqual(bouncer(["a", "b", "c"]), ["a", "b", "c"], "<code>bouncer(["a", "b", "c"])</code> should return <code>["a", "b", "c"]</code>.");'
- text: '<code>bouncer([false, null, 0, NaN, undefined, &quot;&quot;])</code> يجب أن يرجع <code>[]</code> .'
testString: 'assert.deepEqual(bouncer([false, null, 0, NaN, undefined, ""]), [], "<code>bouncer([false, null, 0, NaN, undefined, ""])</code> should return <code>[]</code>.");'
- text: '<code>bouncer([1, null, NaN, 2, undefined])</code> يجب أن يرجع <code>[1, 2]</code> .'
testString: 'assert.deepEqual(bouncer([1, null, NaN, 2, undefined]), [1, 2], "<code>bouncer([1, null, NaN, 2, undefined])</code> should return <code>[1, 2]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function bouncer(arr) {
// Don't show a false ID to this bouncer.
return arr;
}
bouncer([7, "ate", "", false, 9]);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,65 @@
---
id: a26cbbe9ad8655a977e1ceb5
title: Find the Longest Word in a String
isRequired: true
challengeType: 5
videoUrl: ''
localeTitle: ابحث عن أطول كلمة في سلسلة
---
## Description
<section id="description"> إرجاع طول الكلمة الأطول في الجملة المتوفرة. يجب أن يكون ردك رقمًا. تذكر استخدام <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> إذا واجهتك مشكلة. اكتب الكود الخاص بك. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>findLongestWordLength(&quot;The quick brown fox jumped over the lazy dog&quot;)</code> يجب إرجاع رقم.
testString: 'assert(typeof findLongestWordLength("The quick brown fox jumped over the lazy dog") === "number", "<code>findLongestWordLength("The quick brown fox jumped over the lazy dog")</code> should return a number.");'
- text: <code>findLongestWordLength(&quot;The quick brown fox jumped over the lazy dog&quot;)</code> يجب أن يعود 6.
testString: 'assert(findLongestWordLength("The quick brown fox jumped over the lazy dog") === 6, "<code>findLongestWordLength("The quick brown fox jumped over the lazy dog")</code> should return 6.");'
- text: <code>findLongestWordLength(&quot;May the force be with you&quot;)</code> 5.
testString: 'assert(findLongestWordLength("May the force be with you") === 5, "<code>findLongestWordLength("May the force be with you")</code> should return 5.");'
- text: <code>findLongestWordLength(&quot;Google do a barrel roll&quot;)</code> 6.
testString: 'assert(findLongestWordLength("Google do a barrel roll") === 6, "<code>findLongestWordLength("Google do a barrel roll")</code> should return 6.");'
- text: <code>findLongestWordLength(&quot;What is the average airspeed velocity of an unladen swallow&quot;)</code> 8.
testString: 'assert(findLongestWordLength("What is the average airspeed velocity of an unladen swallow") === 8, "<code>findLongestWordLength("What is the average airspeed velocity of an unladen swallow")</code> should return 8.");'
- text: <code>findLongestWordLength(&quot;What if we try a super-long word such as otorhinolaryngology&quot;)</code> يجب أن ترجع 19.
testString: 'assert(findLongestWordLength("What if we try a super-long word such as otorhinolaryngology") === 19, "<code>findLongestWordLength("What if we try a super-long word such as otorhinolaryngology")</code> should return 19.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function findLongestWordLength(str) {
return str.length;
}
findLongestWordLength("The quick brown fox jumped over the lazy dog");
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,58 @@
---
id: a6e40f1041b06c996f7b2406
title: Finders Keepers
isRequired: true
challengeType: 5
videoUrl: ''
localeTitle: من يجد شيئا يحتفظ به
---
## Description
<section id="description"> إنشاء دالة تبحث خلال صفيف (الوسيطة الأولى) وإرجاع العنصر الأول في الصفيف الذي يمرر اختبار الحقيقة (الوسيطة الثانية). إذا لم يجتاز أي عنصر الاختبار ، فارجع غير معروف. تذكر استخدام <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> إذا واجهتك مشكلة. حاول إقران البرنامج. اكتب الكود الخاص بك. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; })</code> يجب أن ترجع 8.'
testString: 'assert.strictEqual(findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; }), 8, "<code>findElement([1, 3, 5, 8, 9, 10], function(num) { return num % 2 === 0; })</code> should return 8.");'
- text: '<code>findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; })</code> يجب أن تُرجع غير معرفة.'
testString: 'assert.strictEqual(findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; }), undefined, "<code>findElement([1, 3, 5, 9], function(num) { return num % 2 === 0; })</code> should return undefined.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function findElement(arr, func) {
let num = 0;
return num;
}
findElement([1, 2, 3, 4], num => num % 2 === 0);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,71 @@
---
id: af2170cad53daa0770fabdea
title: Mutations
isRequired: true
challengeType: 5
videoUrl: ''
localeTitle: الطفرات
---
## Description
<section id="description"> إرجاع true إذا احتوت السلسلة في العنصر الأول من المصفوفة على كافة أحرف السلسلة في العنصر الثاني من الصفيف. على سبيل المثال ، يجب أن تعود <code>[&quot;hello&quot;, &quot;Hello&quot;]</code> ، true لأن كافة الأحرف الموجودة في السلسلة الثانية موجودة في الحالة الأولى ، مع تجاهل الحالة. يجب أن ترجع الوسيطة <code>[&quot;hello&quot;, &quot;hey&quot;]</code> false لأن السلسلة &quot;hello&quot; لا تحتوي على &quot;y&quot;. وأخيرًا ، يجب أن تعود <code>[&quot;Alien&quot;, &quot;line&quot;]</code> ، إلى true لأن جميع الأحرف في &quot;line&quot; موجودة في &quot;Alien&quot;. تذكر استخدام <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> إذا واجهتك مشكلة. اكتب الكود الخاص بك. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: 'يجب أن تعود <code>mutation([&quot;hello&quot;, &quot;hey&quot;])</code> false.'
testString: 'assert(mutation(["hello", "hey"]) === false, "<code>mutation(["hello", "hey"])</code> should return false.");'
- text: 'يجب أن تعود <code>mutation([&quot;hello&quot;, &quot;Hello&quot;])</code> true.'
testString: 'assert(mutation(["hello", "Hello"]) === true, "<code>mutation(["hello", "Hello"])</code> should return true.");'
- text: 'يجب أن ترجع <code>mutation([&quot;zyxwvutsrqponmlkjihgfedcba&quot;, &quot;qrstu&quot;])</code> صحيح.'
testString: 'assert(mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]) === true, "<code>mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])</code> should return true.");'
- text: 'يجب أن تعود <code>mutation([&quot;Mary&quot;, &quot;Army&quot;])</code> الحقيقة.'
testString: 'assert(mutation(["Mary", "Army"]) === true, "<code>mutation(["Mary", "Army"])</code> should return true.");'
- text: 'يجب أن تعود <code>mutation([&quot;Mary&quot;, &quot;Aarmy&quot;])</code> true.'
testString: 'assert(mutation(["Mary", "Aarmy"]) === true, "<code>mutation(["Mary", "Aarmy"])</code> should return true.");'
- text: 'يجب أن تعود <code>mutation([&quot;Alien&quot;, &quot;line&quot;])</code> true.'
testString: 'assert(mutation(["Alien", "line"]) === true, "<code>mutation(["Alien", "line"])</code> should return true.");'
- text: 'يجب أن تعود <code>mutation([&quot;floor&quot;, &quot;for&quot;])</code> true.'
testString: 'assert(mutation(["floor", "for"]) === true, "<code>mutation(["floor", "for"])</code> should return true.");'
- text: 'يجب أن تعود <code>mutation([&quot;hello&quot;, &quot;neo&quot;])</code> false.'
testString: 'assert(mutation(["hello", "neo"]) === false, "<code>mutation(["hello", "neo"])</code> should return false.");'
- text: 'يجب أن تعود <code>mutation([&quot;voodoo&quot;, &quot;no&quot;])</code> كاذبة.'
testString: 'assert(mutation(["voodoo", "no"]) === false, "<code>mutation(["voodoo", "no"])</code> should return false.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function mutation(arr) {
return arr;
}
mutation(["hello", "hey"]);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,68 @@
---
id: afcc8d540bea9ea2669306b6
title: Repeat a String Repeat a String
isRequired: true
challengeType: 5
videoUrl: ''
localeTitle: كرر سلسلة يكرر سلسلة
---
## Description
<section id="description"> كرر <code>str</code> سلسلة معينة (الوسيطة الأولى) لـ <code>num</code> times (الوسيطة الثانية). إرجاع سلسلة فارغة إذا لم تكن <code>num</code> رقم موجب. تذكر استخدام <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> إذا واجهتك مشكلة. اكتب الكود الخاص بك. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: 'يجب أن ترجع <code>repeatStringNumTimes(&quot;*&quot;, 3)</code> <code>&quot;***&quot;</code> .'
testString: 'assert(repeatStringNumTimes("*", 3) === "***", "<code>repeatStringNumTimes("*", 3)</code> should return <code>"***"</code>.");'
- text: 'يجب أن ترجع <code>repeatStringNumTimes(&quot;abc&quot;, 3)</code> <code>&quot;abcabcabc&quot;</code> .'
testString: 'assert(repeatStringNumTimes("abc", 3) === "abcabcabc", "<code>repeatStringNumTimes("abc", 3)</code> should return <code>"abcabcabc"</code>.");'
- text: 'يجب أن ترجع <code>repeatStringNumTimes(&quot;abc&quot;, 4)</code> <code>&quot;abcabcabcabc&quot;</code> .'
testString: 'assert(repeatStringNumTimes("abc", 4) === "abcabcabcabc", "<code>repeatStringNumTimes("abc", 4)</code> should return <code>"abcabcabcabc"</code>.");'
- text: 'يجب أن ترجع <code>repeatStringNumTimes(&quot;abc&quot;, 1)</code> <code>&quot;abc&quot;</code> .'
testString: 'assert(repeatStringNumTimes("abc", 1) === "abc", "<code>repeatStringNumTimes("abc", 1)</code> should return <code>"abc"</code>.");'
- text: 'يجب أن ترجع <code>repeatStringNumTimes(&quot;*&quot;, 8)</code> <code>&quot;********&quot;</code> .'
testString: 'assert(repeatStringNumTimes("*", 8) === "********", "<code>repeatStringNumTimes("*", 8)</code> should return <code>"********"</code>.");'
- text: 'يجب أن ترجع <code>repeatStringNumTimes(&quot;abc&quot;, -2)</code> <code>&quot;&quot;</code> .'
testString: 'assert(repeatStringNumTimes("abc", -2) === "", "<code>repeatStringNumTimes("abc", -2)</code> should return <code>""</code>.");'
- text: لا يجب استخدام <code>repeat()</code> المدمج <code>repeat()</code> -method
testString: 'assert(!/\.repeat/g.test(code), "The built-in <code>repeat()</code>-method should not be used");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function repeatStringNumTimes(str, num) {
// repeat after me
return str;
}
repeatStringNumTimes("abc", 3);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,62 @@
---
id: a789b3483989747d63b0e427
title: Return Largest Numbers in Arrays
isRequired: true
challengeType: 5
videoUrl: ''
localeTitle: أكبر عدد من المصفوفات في المصفوفة
---
## Description
<section id="description"> قم بإرجاع صفيف يتكون من أكبر رقم من كل صفيف فرعي. بالنسبة إلى البساطة ، سيحتوي الصفيف الذي تم توفيره على 4 صفيف فرعي تمامًا. تذكر ، يمكنك التكرار من خلال صفيف مع حلقة بسيطة ، والوصول إلى كل عضو مع <code>arr[i]</code> جملة <code>arr[i]</code> . تذكر استخدام <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> إذا واجهتك مشكلة. اكتب الكود الخاص بك. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])</code> بإرجاع صفيف.'
testString: 'assert(largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]).constructor === Array, "<code>largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]])</code> should return an array.");'
- text: '<code>largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]])</code> يجب أن تعود <code>[27, 5, 39, 1001]</code> .'
testString: 'assert.deepEqual(largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]]), [27, 5, 39, 1001], "<code>largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]])</code> should return <code>[27, 5, 39, 1001]</code>.");'
- text: '<code>largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]])</code> يجب أن تعود <code>[9, 35, 97, 1000000]</code> .'
testString: 'assert.deepEqual(largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]]), [9, 35, 97, 1000000], "<code>largestOfFour([[4, 9, 1, 3], [13, 35, 18, 26], [32, 35, 97, 39], [1000000, 1001, 857, 1]])</code> should return <code>[9, 35, 97, 1000000]</code>.");'
- text: '<code>largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]])</code> should should return <code>[25, 48, 21, -3]</code> .'
testString: 'assert.deepEqual(largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]]), [25, 48, 21, -3], "<code>largestOfFour([[17, 23, 25, 12], [25, 7, 34, 48], [4, -10, 18, 21], [-72, -3, -17, -10]])</code> should return <code>[25, 48, 21, -3]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function largestOfFour(arr) {
// You can do this!
return arr;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,61 @@
---
id: a202eed8fc186c8434cb6d61
title: Reverse a String
isRequired: true
challengeType: 5
videoUrl: ''
localeTitle: عكس سلسلة
---
## Description
<section id="description"> عكس السلسلة المقدمة. قد تحتاج إلى تحويل السلسلة إلى مصفوفة قبل أن تتمكن من عكسها. يجب أن تكون النتيجة الخاصة بك سلسلة. تذكر استخدام <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> إذا واجهتك مشكلة. اكتب الكود الخاص بك. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>reverseString(&quot;hello&quot;)</code> يجب إرجاع سلسلة.
testString: 'assert(typeof reverseString("hello") === "string", "<code>reverseString("hello")</code> should return a string.");'
- text: يجب أن تصبح <code>reverseString(&quot;hello&quot;)</code> <code>&quot;olleh&quot;</code> .
testString: 'assert(reverseString("hello") === "olleh", "<code>reverseString("hello")</code> should become <code>"olleh"</code>.");'
- text: يجب أن تصبح <code>reverseString(&quot;Howdy&quot;)</code> <code>&quot;ydwoH&quot;</code> .
testString: 'assert(reverseString("Howdy") === "ydwoH", "<code>reverseString("Howdy")</code> should become <code>"ydwoH"</code>.");'
- text: يجب أن ترجع <code>reverseString(&quot;Greetings from Earth&quot;)</code> <code>&quot;htraE morf sgniteerG&quot;</code> .
testString: 'assert(reverseString("Greetings from Earth") === "htraE morf sgniteerG", "<code>reverseString("Greetings from Earth")</code> should return <code>"htraE morf sgniteerG"</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function reverseString(str) {
return str;
}
reverseString("hello");
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,75 @@
---
id: 579e2a2c335b9d72dd32e05c
title: Slice and Splice
isRequired: true
isBeta: true
challengeType: 5
videoUrl: ''
localeTitle: شريحة و لصق
---
## Description
<section id="description"> يتم منحك صفيفين ومؤشر. استخدم <code>slice</code> الطرق <code>splice</code> لنسخ كل عنصر من المصفوفة الأولى في المصفوفة الثانية ، بالترتيب. ابدأ بإدخال عناصر في الفهرس <code>n</code> للمصفوفة الثانية. إرجاع الصفيف الناتج. يجب أن تظل صفائف الإدخال كما هي بعد تشغيل الدالة. تذكر استخدام <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> إذا واجهتك مشكلة. اكتب الكود الخاص بك. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>frankenSplice([1, 2, 3], [4, 5], 1)</code> يجب أن ترجع <code>[4, 1, 2, 3, 5]</code> .'
testString: 'assert.deepEqual(frankenSplice([1, 2, 3], [4, 5], 1), [4, 1, 2, 3, 5], "<code>frankenSplice([1, 2, 3], [4, 5], 1)</code> should return <code>[4, 1, 2, 3, 5]</code>.");'
- text: '<code>frankenSplice([1, 2], [&quot;a&quot;, &quot;b&quot;], 1)</code> يجب أن ترجع <code>[&quot;a&quot;, 1, 2, &quot;b&quot;]</code> .'
testString: 'assert.deepEqual(frankenSplice(testArr1, testArr2, 1), ["a", 1, 2, "b"], "<code>frankenSplice([1, 2], ["a", "b"], 1)</code> should return <code>["a", 1, 2, "b"]</code>.");'
- text: '<code>frankenSplice([&quot;claw&quot;, &quot;tentacle&quot;], [&quot;head&quot;, &quot;shoulders&quot;, &quot;knees&quot;, &quot;toes&quot;], 2)</code> يجب أن تعود <code>[&quot;head&quot;, &quot;shoulders&quot;, &quot;claw&quot;, &quot;tentacle&quot;, &quot;knees&quot;, &quot;toes&quot;]</code> .'
testString: 'assert.deepEqual(frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2), ["head", "shoulders", "claw", "tentacle", "knees", "toes"], "<code>frankenSplice(["claw", "tentacle"], ["head", "shoulders", "knees", "toes"], 2)</code> should return <code>["head", "shoulders", "claw", "tentacle", "knees", "toes"]</code>.");'
- text: يجب إضافة جميع العناصر من الصفيف الأول إلى المصفوفة الثانية بترتيبها الأصلي.
testString: 'assert.deepEqual(frankenSplice([1, 2, 3, 4], [], 0), [1, 2, 3, 4], "All elements from the first array should be added to the second array in their original order.");'
- text: يجب أن يظل الصفيف الأول كما هو بعد تشغيل الدالة.
testString: 'assert(testArr1[0] === 1 && testArr1[1] === 2, "The first array should remain the same after the function runs.");'
- text: يجب أن يظل الصفيف الثاني كما هو بعد تشغيل الدالة.
testString: 'assert(testArr2[0] === "a" && testArr2[1] === "b", "The second array should remain the same after the function runs.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function frankenSplice(arr1, arr2, n) {
// It's alive. It's alive!
return arr2;
}
frankenSplice([1, 2, 3], [4, 5, 6], 1);
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,61 @@
---
id: ab6137d4e35944e21037b769
title: Title Case a Sentence
isRequired: true
challengeType: 5
videoUrl: ''
localeTitle: العنوان حالة الجملة
---
## Description
<section id="description"> قم بإرجاع السلسلة المتوفرة بالحرف الأول من كل كلمة بالأحرف الكبيرة. تأكد من أن بقية الكلمة في حالة الأحرف الصغيرة. لأغراض هذا التمرين ، يجب أيضًا تكبير الحروف الموصولة مثل &quot;the&quot; و &quot;of&quot;. تذكر استخدام <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> إذا واجهتك مشكلة. اكتب الكود الخاص بك. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>titleCase(&quot;I&#39;m a little tea pot&quot;)</code> سلسلة.'
testString: 'assert(typeof titleCase("I"m a little tea pot") === "string", "<code>titleCase("I&#39;m a little tea pot")</code> should return a string.");'
- text: '<code>titleCase(&quot;I&#39;m a little tea pot&quot;)</code> يجب أن أعود <code>I&#39;m A Little Tea Pot</code> .'
testString: 'assert(titleCase("I"m a little tea pot") === "I"m A Little Tea Pot", "<code>titleCase("I&#39;m a little tea pot")</code> should return <code>I&#39;m A Little Tea Pot</code>.");'
- text: يجب أن ترجع <code>titleCase(&quot;sHoRt AnD sToUt&quot;)</code> <code>Short And Stout</code> .
testString: 'assert(titleCase("sHoRt AnD sToUt") === "Short And Stout", "<code>titleCase("sHoRt AnD sToUt")</code> should return <code>Short And Stout</code>.");'
- text: <code>titleCase(&quot;HERE IS MY HANDLE HERE IS MY SPOUT&quot;)</code> <code>Here Is My Handle Here Is My Spout</code> <code>titleCase(&quot;HERE IS MY HANDLE HERE IS MY SPOUT&quot;)</code> يجب أن يعود <code>Here Is My Handle Here Is My Spout</code> .
testString: 'assert(titleCase("HERE IS MY HANDLE HERE IS MY SPOUT") === "Here Is My Handle Here Is My Spout", "<code>titleCase("HERE IS MY HANDLE HERE IS MY SPOUT")</code> should return <code>Here Is My Handle Here Is My Spout</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function titleCase(str) {
return str;
}
titleCase("I'm a little tea pot");
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,66 @@
---
id: ac6993d51946422351508a41
title: Truncate a String
isRequired: true
challengeType: 5
videoUrl: ''
localeTitle: اقتطاع سلسلة
---
## Description
<section id="description"> اقتطاع سلسلة (الوسيطة الأولى) إذا كانت أطول من طول السلسلة الأقصى المحدد (الوسيطة الثانية). إرجاع السلسلة المقتطعة مع <code>...</code> إنهاء. تذكر استخدام <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> إذا واجهتك مشكلة. اكتب الكود الخاص بك. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>truncateString(&quot;A-tisket a-tasket A green and yellow basket&quot;, 8)</code> يجب أن ترجع &quot;A-tisket ...&quot;.'
testString: 'assert(truncateString("A-tisket a-tasket A green and yellow basket", 8) === "A-tisket...", "<code>truncateString("A-tisket a-tasket A green and yellow basket", 8)</code> should return "A-tisket...".");'
- text: '<code>truncateString(&quot;Peter Piper picked a peck of pickled peppers&quot;, 11)</code> يجب أن ترجع &quot;بيتر بايبر ...&quot;.'
testString: 'assert(truncateString("Peter Piper picked a peck of pickled peppers", 11) === "Peter Piper...", "<code>truncateString("Peter Piper picked a peck of pickled peppers", 11)</code> should return "Peter Piper...".");'
- text: '<code>truncateString(&quot;A-tisket a-tasket A green and yellow basket&quot;, &quot;A-tisket a-tasket A green and yellow basket&quot;.length)</code> يجب أن تعود <code>truncateString(&quot;A-tisket a-tasket A green and yellow basket&quot;, &quot;A-tisket a-tasket A green and yellow basket&quot;.length)</code> &quot;A-tisket a-tasket سلة خضراء وصفراء&quot;.'
testString: 'assert(truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length) === "A-tisket a-tasket A green and yellow basket", "<code>truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length)</code> should return "A-tisket a-tasket A green and yellow basket".");'
- text: '<code>truncateString(&quot;A-tisket a-tasket A green and yellow basket&quot;, &quot;A-tisket a-tasket A green and yellow basket&quot;.length + 2)</code> يجب أن تعود <code>truncateString(&quot;A-tisket a-tasket A green and yellow basket&quot;, &quot;A-tisket a-tasket A green and yellow basket&quot;.length + 2)</code> &quot;A-tisket a-tasket سلة خضراء وصفراء&quot;.'
testString: 'assert(truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2) === "A-tisket a-tasket A green and yellow basket", "<code>truncateString("A-tisket a-tasket A green and yellow basket", "A-tisket a-tasket A green and yellow basket".length + 2)</code> should return "A-tisket a-tasket A green and yellow basket".");'
- text: 'يجب أن ترجع <code>truncateString(&quot;A-&quot;, 1)</code> &quot;A ...&quot;.'
testString: 'assert(truncateString("A-", 1) === "A...", "<code>truncateString("A-", 1)</code> should return "A...".");'
- text: 'يجب أن ترجع <code>truncateString(&quot;Absolutely Longer&quot;, 2)</code> &quot;Ab ...&quot;.'
testString: 'assert(truncateString("Absolutely Longer", 2) === "Ab...", "<code>truncateString("Absolutely Longer", 2)</code> should return "Ab...".");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function truncateString(str, num) {
// Clear out that junk in your trunk
return str;
}
truncateString("A-tisket a-tasket A green and yellow basket", 8);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,86 @@
---
id: a24c1a4622e3c05097f71d67
title: Where do I Belong
isRequired: true
challengeType: 5
videoUrl: ''
localeTitle: إلى أين أنتمي
---
## Description
<section id="description"> قم بإرجاع أدنى مؤشر يتم فيه إدراج قيمة (وسيطة ثانية) في صفيف (وسيطة أولى) بمجرد فرزها. يجب أن تكون القيمة التي تم إرجاعها رقمًا. على سبيل المثال ، يجب أن تقوم <code>getIndexToIns([1,2,3,4], 1.5)</code> بإرجاع <code>1</code> لأنه أكبر من <code>1</code> (index 0) ، ولكن أقل من <code>2</code> (index 1). وبالمثل ، يجب أن تعود <code>getIndexToIns([20,3,5], 19)</code> <code>2</code> لأنه بمجرد فرز المصفوفة ستبدو مثل <code>[3,5,20]</code> و <code>19</code> أقل من <code>20</code> (مؤشر 2) وأكبر من <code>5</code> ( مؤشر 1). تذكر استخدام <a href="http://forum.freecodecamp.org/t/how-to-get-help-when-you-are-stuck/19514" target="_blank">Read-Search-Ask</a> إذا واجهتك مشكلة. اكتب الكود الخاص بك. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>getIndexToIns([10, 20, 30, 40, 50], 35)</code> <code>3</code> .'
testString: 'assert(getIndexToIns([10, 20, 30, 40, 50], 35) === 3, "<code>getIndexToIns([10, 20, 30, 40, 50], 35)</code> should return <code>3</code>.");'
- text: '<code>getIndexToIns([10, 20, 30, 40, 50], 35)</code> بإرجاع رقم.'
testString: 'assert(typeof(getIndexToIns([10, 20, 30, 40, 50], 35)) === "number", "<code>getIndexToIns([10, 20, 30, 40, 50], 35)</code> should return a number.");'
- text: '<code>getIndexToIns([10, 20, 30, 40, 50], 30)</code> <code>2</code> .'
testString: 'assert(getIndexToIns([10, 20, 30, 40, 50], 30) === 2, "<code>getIndexToIns([10, 20, 30, 40, 50], 30)</code> should return <code>2</code>.");'
- text: '<code>getIndexToIns([10, 20, 30, 40, 50], 30)</code> بإرجاع رقم.'
testString: 'assert(typeof(getIndexToIns([10, 20, 30, 40, 50], 30)) === "number", "<code>getIndexToIns([10, 20, 30, 40, 50], 30)</code> should return a number.");'
- text: 'يجب أن تعود <code>getIndexToIns([40, 60], 50)</code> <code>1</code> .'
testString: 'assert(getIndexToIns([40, 60], 50) === 1, "<code>getIndexToIns([40, 60], 50)</code> should return <code>1</code>.");'
- text: '<code>getIndexToIns([40, 60], 50)</code> بإرجاع رقم.'
testString: 'assert(typeof(getIndexToIns([40, 60], 50)) === "number", "<code>getIndexToIns([40, 60], 50)</code> should return a number.");'
- text: '<code>getIndexToIns([3, 10, 5], 3)</code> <code>0</code> .'
testString: 'assert(getIndexToIns([3, 10, 5], 3) === 0, "<code>getIndexToIns([3, 10, 5], 3)</code> should return <code>0</code>.");'
- text: '<code>getIndexToIns([3, 10, 5], 3)</code> بإرجاع رقم.'
testString: 'assert(typeof(getIndexToIns([3, 10, 5], 3)) === "number", "<code>getIndexToIns([3, 10, 5], 3)</code> should return a number.");'
- text: '<code>getIndexToIns([5, 3, 20, 3], 5)</code> <code>2</code> .'
testString: 'assert(getIndexToIns([5, 3, 20, 3], 5) === 2, "<code>getIndexToIns([5, 3, 20, 3], 5)</code> should return <code>2</code>.");'
- text: '<code>getIndexToIns([5, 3, 20, 3], 5)</code> بإرجاع رقم.'
testString: 'assert(typeof(getIndexToIns([5, 3, 20, 3], 5)) === "number", "<code>getIndexToIns([5, 3, 20, 3], 5)</code> should return a number.");'
- text: '<code>getIndexToIns([2, 20, 10], 19)</code> <code>2</code> .'
testString: 'assert(getIndexToIns([2, 20, 10], 19) === 2, "<code>getIndexToIns([2, 20, 10], 19)</code> should return <code>2</code>.");'
- text: '<code>getIndexToIns([2, 20, 10], 19)</code> بإرجاع رقم.'
testString: 'assert(typeof(getIndexToIns([2, 20, 10], 19)) === "number", "<code>getIndexToIns([2, 20, 10], 19)</code> should return a number.");'
- text: '<code>getIndexToIns([2, 5, 10], 15)</code> <code>3</code> .'
testString: 'assert(getIndexToIns([2, 5, 10], 15) === 3, "<code>getIndexToIns([2, 5, 10], 15)</code> should return <code>3</code>.");'
- text: '<code>getIndexToIns([2, 5, 10], 15)</code> بإرجاع رقم.'
testString: 'assert(typeof(getIndexToIns([2, 5, 10], 15)) === "number", "<code>getIndexToIns([2, 5, 10], 15)</code> should return a number.");'
- text: 'يجب أن ترجع <code>getIndexToIns([], 1)</code> <code>0</code> .'
testString: 'assert(getIndexToIns([], 1) === 0, "<code>getIndexToIns([], 1)</code> should return <code>0</code>.");'
- text: '<code>getIndexToIns([], 1)</code> بإرجاع رقم.'
testString: 'assert(typeof(getIndexToIns([], 1)) === "number", "<code>getIndexToIns([], 1)</code> should return a number.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function getIndexToIns(arr, num) {
// Find my place in this sorted array.
return num;
}
getIndexToIns([40, 60], 50);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,76 @@
---
id: 587d7b7d367417b2b2512b1d
title: ' Iterate Through the Keys of an Object with a for...in Statement'
challengeType: 1
videoUrl: ''
localeTitle: يتكرر عبر مفاتيح كائن مع لـ ... في بيان
---
## Description
<section id="description"> في بعض الأحيان قد تحتاج إلى التكرار من خلال جميع المفاتيح داخل كائن. يتطلب هذا بناء جملة محددًا في JavaScript يسمى <dfn>for ... في</dfn> العبارة. بالنسبة <code>users</code> ، قد يبدو هذا: <blockquote style=";text-align:right;direction:rtl"> لـ (السماح للمستخدم بالمستخدمين) { <br> console.log (المستخدم)؛ <br><br><br> // سجلات: <br> آلان <br> جيف <br> ساره <br> ريان </blockquote> في هذا البيان ، قمنا بتعريف <code>user</code> متغير ، وكما ترى ، تمت إعادة تعيين هذا المتغير أثناء كل عملية تكرار لكل مفتاح من مفاتيح الكائن كالتعبير المتكرر من خلال الكائن ، مما أدى إلى طباعة اسم كل مستخدم إلى وحدة التحكم. <strong>ملحوظة:</strong> <br> لا تحتفظ الكائنات بأمر على المفاتيح المخزنة مثل المصفوفات؛ وبالتالي ، يكون موضع المفاتيح في كائن ما ، أو الترتيب النسبي الذي يظهر فيه ، غير ذي صلة عند الإشارة إلى هذا المفتاح أو الوصول إليه. </section>
## Instructions
<section id="instructions"> لقد قمنا بتعريف وظيفة ، <code>countOnline</code> ؛ استخدم عبارة <dfn>for ... في</dfn> العبارة داخل هذه الوظيفة للتكرار بين المستخدمين في كائن <code>users</code> وإرجاع عدد المستخدمين الذين تم تعيين الخاصية الخاصة بهم <code>online</code> إلى <code>true</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يحتوي كائن <code>users</code> على المستخدمين <code>Jeff</code> <code>Ryan</code> مع تعيين <code>online</code> على <code>true</code> والمستخدمين <code>Alan</code> <code>Sarah</code> مع تعيين <code>online</code> إلى <code>false</code>
testString: 'assert(users.Alan.online === false && users.Jeff.online === true && users.Sarah.online === false && users.Ryan.online === true, "The <code>users</code> object contains users <code>Jeff</code> and <code>Ryan</code> with <code>online</code> set to <code>true</code> and users <code>Alan</code> and <code>Sarah</code> with <code>online</code> set to <code>false</code>");'
- text: ترجع الدالة <code>countOnline</code> عدد المستخدمين الذين تم تعيين الخاصية <code>online</code> إلى <code>true</code>
testString: 'assert((function() { users.Harry = {online: true}; users.Sam = {online: true}; users.Carl = {online: true}; return countOnline(users) })() === 5, "The function <code>countOnline</code> returns the number of users with the <code>online</code> property set to <code>true</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
let users = {
Alan: {
age: 27,
online: false
},
Jeff: {
age: 32,
online: true
},
Sarah: {
age: 48,
online: false
},
Ryan: {
age: 19,
online: true
}
};
function countOnline(obj) {
// change code below this line
// change code above this line
}
console.log(countOnline(users));
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,59 @@
---
id: 5a661e0f1068aca922b3ef17
title: Access an Array's Contents Using Bracket Notation
challengeType: 1
videoUrl: ''
localeTitle: الوصول إلى محتويات صفيف باستخدام تدرج قوس
---
## Description
<section id="description"> إن الميزة الأساسية لأي بنية بيانات هي ، بالطبع ، القدرة على تخزين البيانات فحسب ، بل أيضًا القدرة على استرداد البيانات الموجودة في الأمر. والآن ، بعد أن تعلمنا كيفية إنشاء مصفوفة ، فلنبدأ في التفكير في كيفية الوصول إلى معلومات هذا الصفيف. عندما نحدد صفيفًا بسيطًا كما هو موضح أدناه ، يوجد 3 عناصر فيه: <blockquote style=";text-align:right;direction:rtl"> let ourArray = [&quot;a&quot;، &quot;b&quot;، &quot;c&quot;</blockquote> في صفيف ، يحتوي كل عنصر صفيف على <dfn>فهرس</dfn> . يتضاعف هذا المؤشر كموضع لهذا العنصر في الصفيف ، وكيف يمكنك الرجوع إليه. ومع ذلك، فمن المهم أن نلاحظ، أن صفائف جافا سكريبت <dfn>صفر-فهرستها،</dfn> وهذا يعني أن العنصر الأول من مجموعة هو في الواقع في موقف <em><strong>الصفري،</strong></em> وليس الأول. من أجل استرداد عنصر من صفيف ، يمكننا وضع فهرس بين قوسين وإلحاقه بنهاية مصفوفة ، أو بشكل أكثر شيوعًا ، إلى متغير يشير إلى كائن مصفوفة. هذا هو المعروف باسم <dfn>تدوين قوس</dfn> . على سبيل المثال ، إذا أردنا استرداد <code>&quot;a&quot;</code> من <code>ourArray</code> وتعيينه إلى متغير ، فيمكننا القيام بذلك باستخدام الكود التالي: <blockquote style=";text-align:right;direction:rtl"> دع ourVariable = ourArray [0]؛ <br> // our المتغير يساوي &quot;a&quot; </blockquote> بالإضافة إلى الوصول إلى القيمة المرتبطة بفهرس ، يمكنك أيضًا <em>تعيين</em> فهرس لقيمة باستخدام نفس الترميز: <blockquote style=";text-align:right;direction:rtl"> ourArray [1] = &quot;not b anymore&quot;؛ <br> // ourArray الآن تساوي [&quot;a&quot;، &quot;not b anymore&quot;، &quot;c&quot;</blockquote> باستخدام تدوين قوس ، قمنا الآن بإعادة تعيين العنصر في الفهرس 1 من <code>&quot;b&quot;</code> إلى <code>&quot;not b anymore&quot;</code> . </section>
## Instructions
<section id="instructions"> لإكمال هذا التحدي ، قم بتعيين الموضع الثاني (الرقم <code>1</code> ) من <code>myArray</code> إلى أي شيء تريده ، إلى جانب <code>&quot;b&quot;</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>myArray[0]</code> يساوي <code>&quot;a&quot;</code>'
testString: 'assert.strictEqual(myArray[0], "a", "<code>myArray[0]</code> is equal to <code>"a"</code>");'
- text: 'لم يعد <code>myArray[1]</code> مضبوطًا على <code>&quot;b&quot;</code>'
testString: 'assert.notStrictEqual(myArray[1], "b", "<code>myArray[1]</code> is no longer set to <code>"b"</code>");'
- text: '<code>myArray[2]</code> يساوي <code>&quot;c&quot;</code>'
testString: 'assert.strictEqual(myArray[2], "c", "<code>myArray[2]</code> is equal to <code>"c"</code>");'
- text: '<code>myArray[3]</code> يساوي <code>&quot;d&quot;</code>'
testString: 'assert.strictEqual(myArray[3], "d", "<code>myArray[3]</code> is equal to <code>"d"</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
let myArray = ["a", "b", "c", "d"];
// change code below this line
//change code above this line
console.log(myArray);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,73 @@
---
id: 587d7b7c367417b2b2512b1a
title: Access Property Names with Bracket Notation
challengeType: 1
videoUrl: ''
localeTitle: الوصول إلى خاصية الأسماء مع تدرج قوس
---
## Description
<section id="description"> في التحدي الكائن الأول ذكرنا استخدام تدوين قوس كطريقة للوصول إلى قيم الممتلكات باستخدام تقييم متغير. على سبيل المثال ، تخيل أن <code>foods</code> يتم استخدامها في برنامج لسجل النقدية في السوبر ماركت. لدينا بعض الوظائف التي تحدد <code>foods</code> <code>selectedFood</code> ونريد أن نتحقق من أن <code>foods</code> كائن لوجود ذلك الطعام. قد يبدو هذا كالتالي: <blockquote style=";text-align:right;direction:rtl"> السماح selectFood = getCurrentFood (scannedItem)؛ <br> السماح للمخزون = الأطعمة [selectFood] ؛ </blockquote> سيقوم هذا الكود بتقييم القيمة المخزنة في المتغير <code>selectedFood</code> والصادر وإعادة قيمة هذا المفتاح في كائن <code>foods</code> ، أو يتم <code>undefined</code> إذا لم تكن موجودة. يعتبر تدرج قوس مفيد جدًا لأن أحيانًا لا تكون خصائص الكائن معروفة قبل وقت التشغيل أو نحتاج إلى الوصول إليها بطريقة أكثر ديناميكية. </section>
## Instructions
<section id="instructions"> لقد قمنا بتعريف وظيفة ، <code>checkInventory</code> ، الذي يتلقى عنصرًا تم مسحه ضوئيًا كوسيطة. قم <code>scannedItem</code> القيمة الحالية لمفتاح <code>scannedItem</code> في كائن <code>foods</code> . يمكنك افتراض أنه سيتم توفير المفاتيح الصالحة فقط كوسيطة <code>checkInventory</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>checkInventory</code> هي وظيفة
testString: 'assert.strictEqual(typeof checkInventory, "function", "<code>checkInventory</code> is a function");'
- text: 'يجب أن يحتوي جسم <code>foods</code> على أزواج القيمة الرئيسية التالية: <code>apples: 25</code> ، <code>oranges: 32</code> ، <code>plums: 28</code> ، <code>bananas: 13</code> ، <code>grapes: 35</code> ، <code>strawberries: 27</code>'
testString: 'assert.deepEqual(foods, {apples: 25, oranges: 32, plums: 28, bananas: 13, grapes: 35, strawberries: 27}, "The <code>foods</code> object should have only the following key-value pairs: <code>apples: 25</code>, <code>oranges: 32</code>, <code>plums: 28</code>, <code>bananas: 13</code>, <code>grapes: 35</code>, <code>strawberries: 27</code>");'
- text: <code>checkInventory(&quot;apples&quot;)</code> <code>25</code>
testString: 'assert.strictEqual(checkInventory("apples"), 25, "<code>checkInventory("apples")</code> should return <code>25</code>");'
- text: <code>checkInventory(&quot;bananas&quot;)</code> <code>13</code>
testString: 'assert.strictEqual(checkInventory("bananas"), 13, "<code>checkInventory("bananas")</code> should return <code>13</code>");'
- text: <code>checkInventory(&quot;strawberries&quot;)</code> <code>27</code>
testString: 'assert.strictEqual(checkInventory("strawberries"), 27, "<code>checkInventory("strawberries")</code> should return <code>27</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
let foods = {
apples: 25,
oranges: 32,
plums: 28,
bananas: 13,
grapes: 35,
strawberries: 27
};
// do not change code above this line
function checkInventory(scannedItem) {
// change code below this line
}
// change code below this line to test different cases:
console.log(checkInventory("apples"));
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,61 @@
---
id: 587d78b2367417b2b2512b0e
title: Add Items to an Array with push() and unshift()
challengeType: 1
videoUrl: ''
localeTitle: إضافة عناصر إلى مصفوفة بدفع () و unshift ()
---
## Description
<section id="description"> لم يتم إصلاح طول الصفيف ، مثل أنواع البيانات التي يمكن أن تحتويها. يمكن تعريف المصفوفات بطول أي عدد من العناصر ، ويمكن إضافة العناصر أو إزالتها بمرور الوقت ؛ بمعنى آخر ، المصفوفات <dfn>قابلة للتغيير</dfn> . في هذا التحدي ، سننظر في طريقتين يمكننا من <code>Array.push()</code> تعديل صفيف <code>Array.push()</code> : <code>Array.push()</code> و <code>Array.unshift()</code> . تأخذ كلتا الطريقتين عنصرًا واحدًا أو أكثر كمعلمات وإضافة هذه العناصر إلى الصفيف الذي يتم استدعاء الأسلوب عليه؛ تضيف طريقة <code>push()</code> عناصر إلى نهاية صفيف ، <code>unshift()</code> عناصر إلى البداية. خذ بعين الاعتبار ما يلي: <blockquote style=";text-align:right;direction:rtl"> واسمحوا twentyThree = &#39;الثالث والعشرون&#39; ؛ <br> let romanNumerals = [&#39;XXI&#39;، &#39;XXII&#39;<br><br> romanNumerals.unshift (&#39;XIX&#39;، &#39;XX&#39;<br> // الآن تساوي [&#39;XIX&#39; ، &#39;XX&#39; ، &#39;XXI&#39; ، &#39;XXII&#39;] <br><br> romanNumerals.push (twentyThree)؛ <br> // الآن تساوي [&#39;XIX&#39;، &#39;XX&#39;، &#39;XXI&#39;، &#39;XXII&#39;، &#39;XXIII&#39;] لاحظ أنه يمكننا أيضًا تمرير المتغيرات ، مما يتيح لنا مرونة أكبر في تعديل بيانات المصفوفة ديناميكيًا. </blockquote></section>
## Instructions
<section id="instructions"> لقد حددنا وظيفة ، <code>mixedNumbers</code> ، والتي نحن نمرر مصفوفة كحجة. قم بتعديل الوظيفة باستخدام <code>push()</code> و <code>unshift()</code> لإضافة <code>&#39;I&#39;, 2, &#39;three&#39;</code> إلى بداية الصفيف و <code>7, &#39;VIII&#39;, 9</code> إلى النهاية بحيث يحتوي الصفيف الذي تم إرجاعه على تمثيلات للأرقام 1-9 بالترتيب. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>mixedNumbers([&quot;IV&quot;, 5, &quot;six&quot;])</code> يجب أن تعود الآن <code>[&quot;I&quot;, 2, &quot;three&quot;, &quot;IV&quot;, 5, &quot;six&quot;, 7, &quot;VIII&quot;, 9]</code>'
testString: 'assert.deepEqual(mixedNumbers(["IV", 5, "six"]), ["I", 2, "three", "IV", 5, "six", 7, "VIII", 9], "<code>mixedNumbers(["IV", 5, "six"])</code> should now return <code>["I", 2, "three", "IV", 5, "six", 7, "VIII", 9]</code>");'
- text: يجب استخدام الدالة <code>mixedNumbers</code> الأسلوب <code>push()</code>
testString: 'assert.notStrictEqual(mixedNumbers.toString().search(/\.push\(/), -1, "The <code>mixedNumbers</code> function should utilize the <code>push()</code> method");'
- text: و <code>mixedNumbers</code> وظيفة يجب الاستفادة من <code>unshift()</code> طريقة
testString: 'assert.notStrictEqual(mixedNumbers.toString().search(/\.unshift\(/), -1, "The <code>mixedNumbers</code> function should utilize the <code>unshift()</code> method");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function mixedNumbers(arr) {
// change code below this line
// change code above this line
return arr;
}
// do not change code below this line
console.log(mixedNumbers(['IV', 5, 'six']));
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,63 @@
---
id: 587d78b3367417b2b2512b11
title: Add Items Using splice()
challengeType: 1
videoUrl: ''
localeTitle: إضافة عناصر باستخدام لصق ()
---
## Description
<section id="description"> تذكر في التحدي الأخير ذكرنا أن <code>splice()</code> يمكن أن يستغرق ما يصل إلى ثلاثة معلمات؟ حسنا ، يمكننا أن نذهب خطوة أخرى مع <code>splice()</code> - بالإضافة إلى إزالة العناصر ، يمكننا استخدام هذه المعلمة الثالثة ، والتي تمثل واحد أو أكثر من العناصر ، <em>لإضافتها</em> كذلك. يمكن أن يكون هذا مفيدًا بشكل لا يصدق للتبديل السريع لعنصر أو مجموعة من العناصر ، لعنصر آخر. على سبيل المثال ، لنفترض أنك تخزن نظام ألوان لمجموعة من عناصر DOM في مصفوفة ، وتريد تغيير لون بشكل ديناميكي بناءً على إجراء ما: <blockquote style=";text-align:right;direction:rtl"> function colorChange (arr، index، newColor) { <br> arr.splice (index، 1، newColor)؛ <br> عودة arr؛ <br> } <br><br> let colorScheme = [&#39;# 878787&#39;، &#39;# a08794&#39;، &#39;# bb7e8c&#39;، &#39;# c9b6be&#39;، &#39;# d1becf&#39;<br><br> colorScheme = colorChange (colorScheme، 2، &#39;# 332327&#39;<br> // أزلنا &#39;# bb7e8c&#39; وأضفنا &#39;# 332327&#39; في مكانها <br> // colorScheme now equalals &#39;&#39; # 878787 &#39;،&#39; # a08794 &#39;،&#39; # 332327 &#39;،&#39; # c9b6be &#39;،&#39; # d1becf &#39;] </blockquote> تأخذ هذه الدالة صفيفًا من القيم السداسية ، وهو فهرس يتم عنده إزالة عنصر ، واللون الجديد لاستبدال العنصر المُزال به. قيمة الإرجاع هي صفيف يحتوي على نظام ألوان تم تعديله حديثًا! في حين أن هذا المثال مفرط في التبسيط ، يمكننا أن نرى القيمة التي يمكن أن تستخدم بها <code>splice()</code> إلى أقصى إمكاناتها. </section>
## Instructions
<section id="instructions"> لقد حددنا وظيفة ، <code>htmlColorNames</code> ، والتي تأخذ مصفوفة من ألوان HTML كوسيطة. قم بتعديل الوظيفة باستخدام <code>splice()</code> لإزالة العنصرين الأولين من الصفيف وأضف <code>&#39;DarkSalmon&#39;</code> و <code>&#39;BlanchedAlmond&#39;</code> في <code>&#39;DarkSalmon&#39;</code> الخاصة. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: 'يجب أن <code>htmlColorNames</code> <code>[&quot;DarkSalmon&quot;, &quot;BlanchedAlmond&quot;, &quot;LavenderBlush&quot;, &quot;PaleTurqoise&quot;, &quot;FireBrick&quot;]</code>'
testString: 'assert.deepEqual(htmlColorNames(["DarkGoldenRod", "WhiteSmoke", "LavenderBlush", "PaleTurqoise", "FireBrick"]), ["DarkSalmon", "BlanchedAlmond", "LavenderBlush", "PaleTurqoise", "FireBrick"], "<code>htmlColorNames</code> should return <code>["DarkSalmon", "BlanchedAlmond", "LavenderBlush", "PaleTurqoise", "FireBrick"]</code>");'
- text: يجب أن تستخدم الدالة <code>htmlColorNames</code> الأسلوب <code>splice()</code>
testString: 'assert(/.splice/.test(code), "The <code>htmlColorNames</code> function should utilize the <code>splice()</code> method");'
- text: يجب عدم استخدام <code>shift()</code> أو <code>unshift()</code> .
testString: 'assert(!/shift|unshift/.test(code), "You should not use <code>shift()</code> or <code>unshift()</code>.");'
- text: يجب عدم استخدام تدوين قوس الصفيف.
testString: 'assert(!/\[\d\]\s*=/.test(code), "You should not use array bracket notation.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function htmlColorNames(arr) {
// change code below this line
// change code above this line
return arr;
}
// do not change code below this line
console.log(htmlColorNames(['DarkGoldenRod', 'WhiteSmoke', 'LavenderBlush', 'PaleTurqoise', 'FireBrick']));
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,67 @@
---
id: 587d7b7c367417b2b2512b18
title: Add Key-Value Pairs to JavaScript Objects
challengeType: 1
videoUrl: ''
localeTitle: إضافة أزواج Key-Value إلى كائنات JavaScript
---
## Description
<section id="description"> في أبسط صورها ، تكون الكائنات مجرد مجموعات من <dfn>أزواج القيمة الرئيسية</dfn> ، أو بعبارة أخرى ، أجزاء من البيانات تم تعيينها لمعرفات فريدة نسميها <dfn>خصائص</dfn> أو <dfn>مفاتيح</dfn> . دعونا نلقي نظرة على مثال بسيط جدا: <blockquote style=";text-align:right;direction:rtl"> اترك FCC_User = { <br> اسم المستخدم: &quot;awesome_coder&quot; ، <br> المتابعون: 572 ، <br> النقاط: 1741 ، <br> completedProjects: 15 <br></blockquote> يعرّف الرمز أعلاه كائن يسمى <code>FCC_User</code> يحتوي على أربعة <dfn>خصائص</dfn> ، كل منها تعيين إلى قيمة محددة. إذا أردنا معرفة عدد <code>followers</code> <code>FCC_User</code> ، فيمكننا الوصول إلى ذلك الموقع بكتابة: <blockquote style=";text-align:right;direction:rtl"> السماح userData = FCC_User.followers؛ <br> // userData يساوي 572 </blockquote> هذا ما يسمى <dfn>dot notation</dfn> . بدلاً من ذلك ، يمكننا أيضًا الوصول إلى مكان الإقامة باستخدام الأقواس ، مثل: <blockquote style=";text-align:right;direction:rtl"> السماح لـ userData = FCC_User [&#39;المتابعين&#39;] <br> // userData يساوي 572 </blockquote> لاحظ أنه مع <dfn>تدوين قوس</dfn> ، أرفقنا <code>followers</code> في علامات اقتباس. هذا لأن الأقواس تسمح لنا بالفعل بتمرير متغير ليتم تقييمه كاسم خاصية (تلميح: ضع ذلك في الاعتبار لاحقًا!). لو مررنا <code>followers</code> بدون علامات الاقتباس ، كان محرك جافا سكريبت قد حاول تقييمه كمتغير ، وكان من <code>ReferenceError: followers is not defined</code> . </section>
## Instructions
<section id="instructions"> باستخدام نفس الصيغة ، يمكننا أيضًا <em><strong>إضافة</strong></em> أزواج قيمة رئيسية <em><strong>جديدة</strong></em> إلى الكائنات. لقد أنشأنا كائن <code>foods</code> مع ثلاثة مداخل. أضف ثلاثة إدخالات إضافية: <code>bananas</code> بقيمة <code>13</code> ، <code>grapes</code> بقيمة <code>35</code> ، <code>strawberries</code> بقيمة <code>27</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>foods</code> هي كائن
testString: 'assert(typeof foods === "object", "<code>foods</code> is an object");'
- text: يحتوي جسم <code>foods</code> على <code>&quot;bananas&quot;</code> رئيسي بقيمة <code>13</code>
testString: 'assert(foods.bananas === 13, "The <code>foods</code> object has a key <code>"bananas"</code> with a value of <code>13</code>");'
- text: يحتوي جسم <code>foods</code> على <code>&quot;grapes&quot;</code> الرئيسي بقيمة <code>35</code>
testString: 'assert(foods.grapes === 35, "The <code>foods</code> object has a key <code>"grapes"</code> with a value of <code>35</code>");'
- text: يحتوي جسم <code>foods</code> على <code>&quot;strawberries&quot;</code> الرئيسية بقيمة <code>27</code>
testString: 'assert(foods.strawberries === 27, "The <code>foods</code> object has a key <code>"strawberries"</code> with a value of <code>27</code>");'
- text: يجب تعيين أزواج القيم الأساسية باستخدام تدوين النقطة أو القوس
testString: 'assert(code.search(/bananas:/) === -1 && code.search(/grapes:/) === -1 && code.search(/strawberries:/) === -1, "The key-value pairs should be set using dot or bracket notation");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
let foods = {
apples: 25,
oranges: 32,
plums: 28
};
// change code below this line
// change code above this line
console.log(foods);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,64 @@
---
id: 587d7b7b367417b2b2512b14
title: Check For The Presence of an Element With indexOf()
challengeType: 1
videoUrl: ''
localeTitle: التحقق من وجود عنصر مع indexOf ()
---
## Description
<section id="description"> بما أن الصفائف يمكن تغييرها أو <em>تحورها</em> في أي وقت ، فلا يوجد ضمان حول مكان وجود بيانات معينة في صفيف معين ، أو حتى إذا كان هذا العنصر موجودًا حتى. لحسن الحظ ، توفر لنا جافا سكريبت طريقة أخرى مضمنة ، <code>indexOf()</code> ، تسمح لنا بالتحقق بسرعة وسهولة من وجود عنصر في صفيف. تأخذ <code>indexOf()</code> عنصرًا كمعلمة ، وعندما يتم استدعاؤها ، فإنها ترجع الموضع ، أو الفهرس ، لهذا العنصر ، أو <code>-1</code> إذا كان العنصر غير موجود في الصفيف. فمثلا: <blockquote style=";text-align:right;direction:rtl"> السماح للفواكه = [التفاح ، &#39;الكمثرى&#39; ، &#39;البرتقال&#39; ، &#39;الخوخ&#39; ، &#39;الكمثرى&#39;] ؛ <br><br> fruits.indexOf (&quot;التواريخ&quot;) // returns -1 <br> fruit.indexOf (&#39;oranges&#39;) // تُرجع 2 <br> fruits.indexOf (&#39;pears&#39;) // تُرجع 1 ، أول مؤشر موجود فيه العنصر </blockquote></section>
## Instructions
<section id="instructions"> يمكن أن يكون <code>indexOf()</code> مفيدا بشكل لا يصدق للتحقق بسرعة من وجود عنصر في صفيف. لقد حددنا وظيفة ، <code>quickCheck</code> ، والتي تأخذ مصفوفة وعنصر <code>quickCheck</code> . تعديل الدالة باستخدام <code>indexOf()</code> بحيث تقوم بإرجاع <code>true</code> إذا كان العنصر الذي تم تمريره موجودًا على الصفيف ، و <code>false</code> إذا لم يكن موجودًا. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>quickCheck([&quot;squash&quot;, &quot;onions&quot;, &quot;shallots&quot;], &quot;mushrooms&quot;)</code> يجب أن تعود <code>false</code>'
testString: 'assert.strictEqual(quickCheck(["squash", "onions", "shallots"], "mushrooms"), false, "<code>quickCheck(["squash", "onions", "shallots"], "mushrooms")</code> should return <code>false</code>");'
- text: '<code>quickCheck([&quot;squash&quot;, &quot;onions&quot;, &quot;shallots&quot;], &quot;onions&quot;)</code> يجب أن تعود <code>true</code>'
testString: 'assert.strictEqual(quickCheck(["squash", "onions", "shallots"], "onions"), true, "<code>quickCheck(["squash", "onions", "shallots"], "onions")</code> should return <code>true</code>");'
- text: '<code>quickCheck([3, 5, 9, 125, 45, 2], 125)</code> يجب أن <code>quickCheck([3, 5, 9, 125, 45, 2], 125)</code> <code>true</code>'
testString: 'assert.strictEqual(quickCheck([3, 5, 9, 125, 45, 2], 125), true, "<code>quickCheck([3, 5, 9, 125, 45, 2], 125)</code> should return <code>true</code>");'
- text: '<code>quickCheck([true, false, false], undefined)</code> <code>false</code>'
testString: 'assert.strictEqual(quickCheck([true, false, false], undefined), false, "<code>quickCheck([true, false, false], undefined)</code> should return <code>false</code>");'
- text: يجب أن تستخدم الدالة <code>quickCheck</code> الأسلوب <code>indexOf()</code>
testString: 'assert.notStrictEqual(quickCheck.toString().search(/\.indexOf\(/), -1, "The <code>quickCheck</code> function should utilize the <code>indexOf()</code> method");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function quickCheck(arr, elem) {
// change code below this line
// change code above this line
}
// change code here to test different cases:
console.log(quickCheck(['squash', 'onions', 'shallots'], 'mushrooms'));
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,78 @@
---
id: 587d7b7d367417b2b2512b1c
title: Check if an Object has a Property
challengeType: 1
videoUrl: ''
localeTitle: تحقق مما إذا كان الكائن يحتوي على خاصية
---
## Description
<section id="description"> الآن يمكننا إضافة وتعديل وإزالة المفاتيح من الكائنات. ولكن ماذا لو أردنا فقط معرفة ما إذا كان الكائن له خاصية معينة؟ تقدم لنا JavaScript طريقتين مختلفتين للقيام بذلك. واحد يستخدم <code>hasOwnProperty()</code> طريقة والآخر يستخدم <code>in</code> الكلمة. إذا كان لدينا <code>users</code> كائنات <code>users</code> خاصية <code>Alan</code> ، فيمكننا التحقق من وجودها بأي من الطرق التالية: <blockquote style=";text-align:right;direction:rtl"> users.hasOwnProperty (علان &#39;<br> &quot;آلان&quot; في المستخدمين ؛ <br> // كلاهما يعود صحيح </blockquote></section>
## Instructions
<section id="instructions"> لقد أنشأنا كائنًا ، <code>users</code> ، ومع بعض المستخدمين فيه ، ووظيفة هي <code>isEveryoneHere</code> ، والتي <code>isEveryoneHere</code> <code>users</code> ككائن. الانتهاء من كتابة هذه الوظيفة بحيث تقوم بإرجاع <code>true</code> إلا إذا كان <code>users</code> يعترض يحتوي على جميع الأسماء الأربعة، <code>Alan</code> ، <code>Jeff</code> ، <code>Sarah</code> ، و <code>Ryan</code> ، ومفاتيح، و <code>false</code> خلاف ذلك. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يحتوي كائن <code>users</code> فقط على مفاتيح <code>Alan</code> و <code>Jeff</code> و <code>Sarah</code> و <code>Ryan</code>
testString: 'assert("Alan" in users && "Jeff" in users && "Sarah" in users && "Ryan" in users && Object.keys(users).length === 4, "The <code>users</code> object only contains the keys <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code>");'
- text: الدالة <code>isEveryoneHere</code> بإرجاع <code>true</code> إذا كان <code>Alan</code> و <code>Jeff</code> و <code>Sarah</code> و <code>Ryan</code> هي خصائص على كائن <code>users</code>
testString: 'assert(isEveryoneHere(users) === true, "The function <code>isEveryoneHere</code> returns <code>true</code> if <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code> are properties on the <code>users</code> object");'
- text: الدالة <code>isEveryoneHere</code> بإرجاع <code>false</code> إذا كان <code>Alan</code> و <code>Jeff</code> و <code>Sarah</code> و <code>Ryan</code> ليست خصائص على كائن <code>users</code>
testString: 'assert((function() { delete users.Alan; delete users.Jeff; delete users.Sarah; delete users.Ryan; return isEveryoneHere(users) })() === false, "The function <code>isEveryoneHere</code> returns <code>false</code> if <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code> are not properties on the <code>users</code> object");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
let users = {
Alan: {
age: 27,
online: true
},
Jeff: {
age: 32,
online: true
},
Sarah: {
age: 48,
online: true
},
Ryan: {
age: 19,
online: true
}
};
function isEveryoneHere(obj) {
// change code below this line
// change code above this line
}
console.log(isEveryoneHere(users));
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,58 @@
---
id: 587d7b7b367417b2b2512b17
title: Combine Arrays with the Spread Operator
challengeType: 1
videoUrl: ''
localeTitle: الجمع بين المصفوفات مع المشغل انتشار
---
## Description
<section id="description"> ميزة أخرى ضخمة لمشغل <dfn>الانتشار</dfn> ، هي القدرة على الجمع بين المصفوفات ، أو لإدراج جميع عناصر صفيف في آخر ، في أي مؤشر. باستخدام صيغ تركيبية أكثر تقليدية ، يمكننا تجميع صفائف ، لكن هذا يسمح لنا فقط بدمج المصفوفات في نهاية واحد ، وفي بداية أخرى. بناء الجملة Spread يجعل العملية التالية بسيطة للغاية: <blockquote style=";text-align:right;direction:rtl"> دع هذا aarray = [&#39;sage&#39;، &#39;rosemary&#39;، &#39;parsley&#39;، &#39;thyme&#39;<br><br> اترك ذلكالرائحة = [&#39;basil&#39; ، &#39;cilantro&#39; ، ... thisArray ، &#39;الكزبرة&#39;] ؛ <br> / / أن الآن يساوي [basil] ، &#39;cilantro&#39; ، &#39;sage&#39; ، &#39;rosemary&#39; ، &#39;parsley&#39; ، &#39;thyme&#39; ، &#39;coriander&#39;] </blockquote> باستخدام صيغة الانتشار ، حققنا للتو عملية من شأنها أن تكون أكثر تعقيدا وأكثر استعراضا لو استخدمنا الطرق التقليدية. </section>
## Instructions
<section id="instructions"> لقد قمنا بتعريف دالة <code>spreadOut</code> التي تقوم بارجاع <code>sentence</code> المتغيرة ، قم بتعديل الوظيفة باستخدام معامل <dfn>الانتشار</dfn> بحيث يقوم بإرجاع الصفيف <code>[&#39;learning&#39;, &#39;to&#39;, &#39;code&#39;, &#39;is&#39;, &#39;fun&#39;]</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>spreadOut</code> يجب أن تعود <code>[&quot;learning&quot;, &quot;to&quot;, &quot;code&quot;, &quot;is&quot;, &quot;fun&quot;]</code>'
testString: 'assert.deepEqual(spreadOut(), ["learning", "to", "code", "is", "fun"], "<code>spreadOut</code> should return <code>["learning", "to", "code", "is", "fun"]</code>");'
- text: يجب أن تستخدم دالة <code>spreadOut</code> بنية الانتشار
testString: 'assert.notStrictEqual(spreadOut.toString().search(/[...]/), -1, "The <code>spreadOut</code> function should utilize spread syntax");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function spreadOut() {
let fragment = ['to', 'code'];
let sentence; // change this line
return sentence;
}
// do not change code below this line
console.log(spreadOut());
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,69 @@
---
id: 587d7b7b367417b2b2512b13
title: Copy an Array with the Spread Operator
challengeType: 1
videoUrl: ''
localeTitle: نسخ صفيف مع المشغل انتشار
---
## Description
<section id="description"> بينما تسمح لنا <code>slice()</code> بأن نكون انتقائيين حول عناصر المصفوفة المراد نسخها ، من بين العديد من المهام المفيدة الأخرى ، يتيح لنا <dfn>مشغل</dfn> التوزيع الجديد لـ ES6 نسخ <em>جميع</em> عناصر الصفيف بسهولة ، بالترتيب ، مع بناء بسيط وقابل للقراءة للغاية. تبدو صيغة الانتشار بهذا الشكل: <code>...</code> الناحية العملية ، يمكننا استخدام عامل الانتشار لنسخ مصفوفة مثل: <blockquote style=";text-align:right;direction:rtl"> السماح لهذاالصورة = [true، true، undefined، false، null]؛ <br> السماح أن AArray = [... thisArray]؛ <br> // thatArray يساوي [true ، true ، غير محدد ، false ، فارغ] <br> / / هذا لا يزال يظل بدون تغيير ، وهو مطابق لذلك </blockquote></section>
## Instructions
<section id="instructions"> قمنا بتعريف وظيفة ، <code>copyMachine</code> والتي تأخذ <code>arr</code> (صفيف) و <code>num</code> (a number) كوسيطة. من المفترض أن تقوم الدالة بإرجاع صفيف جديد يتكون من نسخ <code>num</code> من <code>arr</code> . لقد قمنا بمعظم العمل لك ، لكنه لا يعمل بشكل صحيح بعد. قم بتعديل الوظيفة باستخدام صيغة الانتشار بحيث تعمل بشكل صحيح (تلميح: قد تكون طريقة أخرى قمنا بتغطيتها بالفعل مفيدة هنا!). </section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>copyMachine([true, false, true], 2)</code> <code>[[true, false, true], [true, false, true]]</code>'
testString: 'assert.deepEqual(copyMachine([true, false, true], 2), [[true, false, true], [true, false, true]], "<code>copyMachine([true, false, true], 2)</code> should return <code>[[true, false, true], [true, false, true]]</code>");'
- text: '<code>copyMachine([1, 2, 3], 5)</code> <code>[[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]</code>'
testString: 'assert.deepEqual(copyMachine([1, 2, 3], 5), [[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]], "<code>copyMachine([1, 2, 3], 5)</code> should return <code>[[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]</code>");'
- text: '<code>copyMachine([true, true, null], 1)</code> يجب أن يعيد <code>[[true, true, null]]</code>'
testString: 'assert.deepEqual(copyMachine([true, true, null], 1), [[true, true, null]], "<code>copyMachine([true, true, null], 1)</code> should return <code>[[true, true, null]]</code>");'
- text: '<code>copyMachine([&quot;it works&quot;], 3)</code> <code>[[&quot;it works&quot;], [&quot;it works&quot;], [&quot;it works&quot;]]</code>'
testString: 'assert.deepEqual(copyMachine(["it works"], 3), [["it works"], ["it works"], ["it works"]], "<code>copyMachine(["it works"], 3)</code> should return <code>[["it works"], ["it works"], ["it works"]]</code>");'
- text: و <code>copyMachine</code> وظيفة يجب الاستفادة من <code>spread operator</code> مع مجموعة <code>arr</code>
testString: 'assert.notStrictEqual(copyMachine.toString().indexOf(".concat(_toConsumableArray(arr))"), -1, "The <code>copyMachine</code> function should utilize the <code>spread operator</code> with array <code>arr</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function copyMachine(arr, num) {
let newArr = [];
while (num >= 1) {
// change code below this line
// change code above this line
num--;
}
return newArr;
}
// change code here to test different cases:
console.log(copyMachine([true, false, true], 2));
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,58 @@
---
id: 587d7b7a367417b2b2512b12
title: Copy Array Items Using slice()
challengeType: 1
videoUrl: ''
localeTitle: نسخ صفيف العناصر باستخدام شريحة ()
---
## Description
<section id="description"> الطريقة التالية التي سنقوم بتغطيتها هي <code>slice()</code> . <code>slice()</code> ، بدلاً من تعديل صفيف أو نسخ أو <em>مقتطفات</em> ، عدد معين من العناصر إلى صفيف جديد ، تاركاً المصفوفة يتم استدعاؤها دون مساس. تأخذ <code>slice()</code> معلمتين فقط - الأولى هي المؤشر الذي يبدأ عنده الاستخراج ، والثاني هو المؤشر الذي يتم عنده إيقاف الاستخراج (يحدث الاستخراج حتى ، ولكن ليس بما في ذلك العنصر في هذا المؤشر). النظر في هذا: <blockquote style=";text-align:right;direction:rtl"> السماح للظروف الجوية = [&#39;المطر&#39; ، &#39;الثلج&#39; ، &#39;المتجمدة&#39; ، &#39;البرد&#39; ، &#39;واضح&#39;] ؛ <br><br> السماح todaysWeather = weatherConditions.slice (1 ، 3) ؛ <br> // todaysWeather يساوي [&#39;snow&#39;، &#39;sleet&#39;<br> // weatherConditions لا يزال يساوي [&#39;المطر&#39; ، &#39;الثلج&#39; ، &#39;المتجمدة&#39; ، &#39;البرد&#39; ، &#39;واضح&#39;] <br></blockquote> في الواقع ، قمنا بإنشاء مصفوفة جديدة عن طريق استخراج عناصر من صفيف موجود. </section>
## Instructions
<section id="instructions"> لقد حددنا دالة ، <code>forecast</code> ، تأخذ صفيفًا كحجة. قم بتعديل الوظيفة باستخدام <code>slice()</code> لاستخراج المعلومات من صفيف الوسيطة وإرجاع صفيف جديد يحتوي على عناصر <code>&#39;warm&#39;</code> و <code>&#39;sunny&#39;</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: 'يجب أن تعود <code>forecast</code> <code>[&quot;warm&quot;, &quot;sunny&quot;]</code>'
testString: 'assert.deepEqual(forecast(["cold", "rainy", "warm", "sunny", "cool", "thunderstorms"]), ["warm", "sunny"], "<code>forecast</code> should return <code>["warm", "sunny"]");'
- text: يجب أن تستخدم وظيفة <code>forecast</code> طريقة <code>slice()</code>
testString: 'assert(/\.slice\(/.test(code), "The <code>forecast</code> function should utilize the <code>slice()</code> method");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function forecast(arr) {
// change code below this line
return arr;
}
// do not change code below this line
console.log(forecast(['cold', 'rainy', 'warm', 'sunny', 'cool', 'thunderstorms']));
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,65 @@
---
id: 587d7b7b367417b2b2512b16
title: Create complex multi-dimensional arrays
challengeType: 1
videoUrl: ''
localeTitle: إنشاء صفائف معقدة متعددة الأبعاد
---
## Description
<section id="description"> رائع! لقد تعلمت للتو عن طن عن المصفوفات! كانت هذه نظرة عامة على مستوى عالٍ إلى حدٍ ما ، وهناك الكثير الذي يجب معرفته حول العمل مع المصفوفات ، والتي سترى الكثير منها في الأقسام التالية. ولكن قبل الانتقال إلى النظر إلى <dfn>الكائنات</dfn> ، دعنا نلقي نظرة أخرى ، ونرى كيف يمكن أن تصبح المصفوفات أكثر تعقيدًا من ما رأيناه في التحديات السابقة. واحدة من أقوى الميزات عند التفكير في المصفوفات كهيكل البيانات ، هي أن المصفوفات يمكن أن تحتوي ، أو حتى تتكون بالكامل من صفائف أخرى. لقد رأينا صفائف تحتوي على مصفوفات في تحديات سابقة ، ولكنها بسيطة نوعًا ما. ومع ذلك ، يمكن أن تحتوي المصفوفات على عمق لا نهائي من المصفوفات التي يمكن أن تحتوي على صفائف أخرى ، كل منها بمستوياتها الاعتباطية الخاصة بها ، وهكذا. وبهذه الطريقة ، يمكن أن تصبح المصفوفة بسرعة كبيرة جدًا بنية بيانات معقدة ، تُعرف باسم مصفوفة <dfn>متعددة الأبعاد</dfn> أو متداخلة. خذ بعين الاعتبار المثال التالي: <blockquote style=";text-align:right;direction:rtl"> اترك nestedArray = [// top، or first level - the external most array] <br> [&#39;عميق&#39;] ، // مصفوفة داخل صفيف ، مستويين من العمق <br> [ <br> [&#39;أعمق&#39;] ، [&#39;أعمق&#39;] // / 2 صفيف متداخلة 3 مستويات عميقة <br><br> [ <br> [ <br> [&#39;أعمق&#39;] ، [أعمق]] / / 2 صفيف متداخلة 4 مستويات عميقة <br><br> [ <br> [ <br> [&#39;deepest-est؟&#39;] // مجموعة متداخلة 5 مستويات عميقة <br> ] <br> ] <br> ] <br> ]. </blockquote> على الرغم من أن هذا المثال قد يبدو معقدًا ، إلا أن هذا المستوى من التعقيد لم يسمع به ، أو حتى غير معتاد ، عند التعامل مع كميات كبيرة من البيانات. ومع ذلك ، لا يزال بإمكاننا الوصول بسهولة إلى أعمق مستويات صفيف هذا المركب مع تدوين قوس: <blockquote style=";text-align:right;direction:rtl"> console.log (nestedArray [2] [1] [0] [0] [0])؛ <br> // logs: deepest-est؟ </blockquote> والآن بعد أن علمنا بمكان هذه البيانات ، يمكننا إعادة تعيينها إذا كنا بحاجة إلى: <blockquote style=";text-align:right;direction:rtl"> nestedArray [2] [1] [0] [0] [0] = &#39;deep still&#39;؛ <br><br> console.log (nestedArray [2] [1] [0] [0] [0])؛ <br> // الآن سجلات: أعمق لا يزال </blockquote></section>
## Instructions
<section id="instructions"> لقد حددنا متغيرًا ، <code>myNestedArray</code> ، متساوياً مع صفيف. تعديل <code>myNestedArray</code> ، وذلك باستخدام أي مجموعة من <dfn>السلاسل</dfn> <dfn>والأرقام</dfn> <dfn>والقيم المنطقية</dfn> لعناصر البيانات، بحيث انها بالضبط خمسة مستويات من العمق (تذكر، ومجموعة الخارجي، أكثر من غيره هو مستوى 1). في مكان ما في المستوى الثالث ، تتضمن السلسلة <code>&#39;deep&#39;</code> ، في المستوى الرابع ، وتشمل السلسلة <code>&#39;deeper&#39;</code> ، وعلى المستوى الخامس ، تتضمن السلسلة <code>&#39;deepest&#39;</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن تحتوي <code>myNestedArray</code> على أرقام فقط ، وحدات منطقية ، وسلاسل مثل عناصر البيانات
testString: 'assert.strictEqual((function(arr) { let flattened = (function flatten(arr) { const flat = [].concat(...arr); return flat.some (Array.isArray) ? flatten(flat) : flat; })(arr); for (let i = 0; i < flattened.length; i++) { if ( typeof flattened[i] !== "number" && typeof flattened[i] !== "string" && typeof flattened[i] !== "boolean") { return false } } return true })(myNestedArray), true, "<code>myNestedArray</code> should contain only numbers, booleans, and strings as data elements");'
- text: يجب أن يكون <code>myNestedArray</code> 5 مستويات عمق
testString: 'assert.strictEqual((function(arr) {let depth = 0;function arrayDepth(array, i, d) { if (Array.isArray(array[i])) { arrayDepth(array[i], 0, d + 1);} else { depth = (d > depth) ? d : depth;}if (i < array.length) { arrayDepth(array, i + 1, d);} }arrayDepth(arr, 0, 0);return depth;})(myNestedArray), 4, "<code>myNestedArray</code> should have exactly 5 levels of depth");'
- text: يجب أن يحتوي <code>myNestedArray</code> على تكرار واحد لسلسلة <code>&quot;deep&quot;</code> على صفيف متداخلة من 3 مستويات
testString: 'assert((function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, "deep").length === 1 && (function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, "deep")[0] === 2, "<code>myNestedArray</code> should contain exactly one occurrence of the string <code>"deep"</code> on an array nested 3 levels deep");'
- text: يجب أن يحتوي <code>myNestedArray</code> على تكرار واحد فقط للسلسلة <code>&quot;deeper&quot;</code> على صفيف متداخلة 4 مستويات متداخلة
testString: 'assert((function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, "deeper").length === 1 && (function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, "deeper")[0] === 3, "<code>myNestedArray</code> should contain exactly one occurrence of the string <code>"deeper"</code> on an array nested 4 levels deep");'
- text: يجب أن يحتوي <code>myNestedArray</code> على تكرار واحد لسلسلة <code>&quot;deepest&quot;</code> على مجموعة متداخلة من 5 مستويات متداخلة
testString: 'assert((function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, "deepest").length === 1 && (function howDeep(array, target, depth = 0) {return array.reduce((combined, current) => {if (Array.isArray(current)) { return combined.concat(howDeep(current, target, depth + 1));} else if (current === target) { return combined.concat(depth);} else { return combined;}}, []);})(myNestedArray, "deepest")[0] === 4, "<code>myNestedArray</code> should contain exactly one occurrence of the string <code>"deepest"</code> on an array nested 5 levels deep");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
let myNestedArray = [
// change code below this line
['unshift', false, 1, 2, 3, 'complex', 'nested'],
['loop', 'shift', 6, 7, 1000, 'method'],
['concat', false, true, 'spread', 'array'],
['mutate', 1327.98, 'splice', 'slice', 'push'],
['iterate', 1.3849, 7, '8.4876', 'arbitrary', 'depth']
// change code above this line
];
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,76 @@
---
id: 587d7b7d367417b2b2512b1e
title: Generate an Array of All Object Keys with Object.keys()
challengeType: 1
videoUrl: ''
localeTitle: إنشاء صفيف من كافة مفاتيح الكائنات مع Object.keys ()
---
## Description
<section id="description"> يمكننا أيضًا إنشاء مصفوفة تحتوي على جميع المفاتيح المخزنة في كائن باستخدام طريقة <code>Object.keys()</code> وتمريرها في كائن كوسيطة. سيؤدي هذا إلى إرجاع صفيف يحتوي على سلاسل تمثل كل خاصية في الكائن. مرة أخرى ، لن يكون هناك طلب محدد للإدخالات في الصفيف. </section>
## Instructions
<section id="instructions"> قم <code>getArrayOfUsers</code> كتابة الدالة <code>getArrayOfUsers</code> بحيث تقوم بإرجاع صفيف يحتوي على كافة الخصائص في الكائن يتلقاها كوسيطة. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يحتوي كائن <code>users</code> فقط على مفاتيح <code>Alan</code> و <code>Jeff</code> و <code>Sarah</code> و <code>Ryan</code>
testString: 'assert("Alan" in users && "Jeff" in users && "Sarah" in users && "Ryan" in users && Object.keys(users).length === 4, "The <code>users</code> object only contains the keys <code>Alan</code>, <code>Jeff</code>, <code>Sarah</code>, and <code>Ryan</code>");'
- text: ترجع الدالة <code>getArrayOfUsers</code> صفيف يحتوي على كافة المفاتيح الموجودة في كائن <code>users</code>
testString: 'assert((function() { users.Sam = {}; users.Lewis = {}; let R = getArrayOfUsers(users); return (R.indexOf("Alan") !== -1 && R.indexOf("Jeff") !== -1 && R.indexOf("Sarah") !== -1 && R.indexOf("Ryan") !== -1 && R.indexOf("Sam") !== -1 && R.indexOf("Lewis") !== -1); })() === true, "The <code>getArrayOfUsers</code> function returns an array which contains all the keys in the <code>users</code> object");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
let users = {
Alan: {
age: 27,
online: false
},
Jeff: {
age: 32,
online: true
},
Sarah: {
age: 48,
online: false
},
Ryan: {
age: 19,
online: true
}
};
function getArrayOfUsers(obj) {
// change code below this line
// change code above this line
}
console.log(getArrayOfUsers(users));
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,66 @@
---
id: 587d7b7b367417b2b2512b15
title: Iterate Through All an Array's Items Using For Loops
challengeType: 1
videoUrl: ''
localeTitle: يتكرر من خلال جميع عناصر المصفوفة عن طريق استخدام الحلقات
---
## Description
<section id="description"> في بعض الأحيان عند العمل مع المصفوفات ، يكون من السهل جدًا التكرار من خلال كل عنصر للعثور على عنصر واحد أو أكثر قد نحتاجه ، أو التعامل مع صفيف استنادًا إلى عناصر البيانات التي تلبي مجموعة معينة من المعايير. تقدم JavaScript العديد من الطرق المضمنة التي يتم تكرار كل منها على المصفوفات بطرق مختلفة قليلاً لتحقيق نتائج مختلفة (مثل <code>every()</code> ، <code>forEach()</code> ، <code>map()</code> ، إلخ. ، ولكن التقنية الأكثر مرونة وتوفر لنا الأعظم مقدار التحكم هو بسيط <code>for</code> حلقة. خذ بعين الاعتبار ما يلي: <blockquote style=";text-align:right;direction:rtl"> وظيفة greaterThanTen (arr) { <br> let newArr = []؛ <br> لـ (let i = 0؛ i &lt;arr.length؛ i ++) { <br> إذا (arr [i]&gt; 10) { <br> newArr.push (آر [أنا])؛ <br> } <br> } <br> عودة newArr ؛ <br> } <br><br> greaterThanTen ([2، 12، 8، 14، 80، 0، 1])؛ <br> // تُرجع [12 ، 14 ، 80] </blockquote> باستخدام حلقة <code>for</code> ، تتكرر هذه الوظيفة خلال كل عنصر في الصفيف وتصل إليه ، وتضعه في اختبار بسيط قمنا بإنشائه. بهذه الطريقة ، حددنا بسهولة وببرمجية أي من عناصر البيانات أكبر من <code>10</code> ، وأعدنا مصفوفة جديدة تحتوي على تلك العناصر. </section>
## Instructions
<section id="instructions"> لقد حددنا دالة ، <code>filteredArray</code> ، والتي تأخذ <code>arr</code> ، ومصفوفة متداخلة ، و <code>elem</code> ، وتقوم بإرجاع صفيف جديد. يمثل <code>elem</code> عنصرًا قد يكون أو لا يكون موجودًا على واحد أو أكثر من الصفائف المتداخلة ضمن <code>arr</code> . قم بتعديل الوظيفة ، باستخدام حلقة <code>for</code> ، لإرجاع نسخة مفلترة من المصفوفة التي تم تمريرها بحيث يتم إزالة أي صفيف متداخل داخل <code>arr</code> يحتوي على <code>elem</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>filteredArray([[10, 8, 3], [14, 6, 23], [3, 18, 6]], 18)</code> يجب أن يعود <code>[ [10, 8, 3], [14, 6, 23] ]</code>'
testString: 'assert.deepEqual(filteredArray([ [10, 8, 3], [14, 6, 23], [3, 18, 6] ], 18), [[10, 8, 3], [14, 6, 23]], "<code>filteredArray([[10, 8, 3], [14, 6, 23], [3, 18, 6]], 18)</code> should return <code>[ [10, 8, 3], [14, 6, 23] ]</code>");'
- text: '<code>filteredArray([ [&quot;trumpets&quot;, 2], [&quot;flutes&quot;, 4], [&quot;saxophones&quot;, 2] ], 2)</code> يجب أن تعود <code>[ [&quot;flutes&quot;, 4] ]</code>'
testString: 'assert.deepEqual(filteredArray([ ["trumpets", 2], ["flutes", 4], ["saxophones", 2] ], 2), [["flutes", 4]], "<code>filteredArray([ ["trumpets", 2], ["flutes", 4], ["saxophones", 2] ], 2)</code> should return <code>[ ["flutes", 4] ]</code>");'
- text: 'يجب أن تعود <code>filteredArray([ [&quot;amy&quot;, &quot;beth&quot;, &quot;sam&quot;], [&quot;dave&quot;, &quot;sean&quot;, &quot;peter&quot;] ], &quot;peter&quot;)</code> <code>[ [&quot;amy&quot;, &quot;beth&quot;, &quot;sam&quot;] ]</code>'
testString: 'assert.deepEqual(filteredArray([["amy", "beth", "sam"], ["dave", "sean", "peter"]], "peter"), [["amy", "beth", "sam"]], "<code>filteredArray([ ["amy", "beth", "sam"], ["dave", "sean", "peter"] ], "peter")</code> should return <code>[ ["amy", "beth", "sam"] ]</code>");'
- text: '<code>filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3)</code> يجب أن تعود <code>[ ]</code>'
testString: 'assert.deepEqual(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3), [], "<code>filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3)</code> should return <code>[ ]</code>");'
- text: و <code>filteredArray</code> وظيفة يجب أن تستخدم ل <code>for</code> حلقة
testString: 'assert.notStrictEqual(filteredArray.toString().search(/for/), -1, "The <code>filteredArray</code> function should utilize a <code>for</code> loop");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function filteredArray(arr, elem) {
let newArr = [];
// change code below this line
// change code above this line
return newArr;
}
// change code here to test different cases:
console.log(filteredArray([[3, 2, 3], [1, 6, 3], [3, 13, 26], [19, 3, 9]], 3));
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,79 @@
---
id: 587d7b7d367417b2b2512b1f
title: Modify an Array Stored in an Object
challengeType: 1
videoUrl: ''
localeTitle: تعديل صفيف مخزنة في كائن
---
## Description
<section id="description"> لقد شاهدت الآن جميع العمليات الأساسية لكائنات جافا سكريبت. يمكنك إضافة أو تعديل أو إزالة أزواج قيمة المفتاح ، والتحقق من وجود المفاتيح ، وتكرارها على كافة المفاتيح الموجودة في كائن ما. أثناء متابعة تعلم لغة JavaScript ، سترى تطبيقات أكثر تنوعًا للكائنات. بالإضافة إلى ذلك ، فإن دروس &quot;هياكل البيانات المتقدمة&quot; الاختيارية في وقت لاحق في المنهج تغطي أيضًا كائنات ES6 <dfn>Map</dfn> و <dfn>Set</dfn> ، وكلاهما مشابهان للكائنات العادية ولكن مع توفير بعض الميزات الإضافية. الآن بعد أن تعلمت أساسيات المصفوفات والأشياء ، فأنت مستعد تمامًا للبدء في معالجة مشكلات أكثر تعقيدًا باستخدام JavaScript! </section>
## Instructions
<section id="instructions"> ألق نظرة على الكائن الذي قدمناه في محرر الشفرات. يحتوي كائن <code>user</code> على ثلاثة مفاتيح. يحتوي مفتاح <code>data</code> على خمسة مفاتيح ، يحتوي أحدها على مجموعة من <code>friends</code> . من هذا ، يمكنك أن ترى كيف الأجسام المرنة هي هياكل البيانات. لقد بدأنا في كتابة وظيفة <code>addFriend</code> . قم بإنهاء الكتابة بحيث تأخذ كائن <code>user</code> وتضيف اسم وسيطة <code>friend</code> إلى الصفيف المخزن في <code>user.data.friends</code> وتقوم بإرجاع هذا الصفيف. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يحتوي كائن <code>user</code> على <code>name</code> <code>age</code> ومفاتيح <code>data</code>
testString: 'assert("name" in user && "age" in user && "data" in user, "The <code>user</code> object has <code>name</code>, <code>age</code>, and <code>data</code> keys");'
- text: تقبل وظيفة <code>addFriend</code> كائن <code>user</code> وسلسلة <code>friend</code> كوسيطة وتضيف الصديق إلى مصفوفة <code>friends</code> في كائن <code>user</code>
testString: 'assert((function() { let L1 = user.data.friends.length; addFriend(user, "Sean"); let L2 = user.data.friends.length; return (L2 === L1 + 1); })(), "The <code>addFriend</code> function accepts a <code>user</code> object and a <code>friend</code> string as arguments and adds the friend to the array of <code>friends</code> in the <code>user</code> object");'
- text: '<code>addFriend(user, &quot;Pete&quot;)</code> <code>[&quot;Sam&quot;, &quot;Kira&quot;, &quot;Tomo&quot;, &quot;Pete&quot;]</code>'
testString: 'assert.deepEqual((function() { delete user.data.friends; user.data.friends = ["Sam", "Kira", "Tomo"]; return addFriend(user, "Pete") })(), ["Sam", "Kira", "Tomo", "Pete"], "<code>addFriend(user, "Pete")</code> should return <code>["Sam", "Kira", "Tomo", "Pete"]</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
let user = {
name: 'Kenneth',
age: 28,
data: {
username: 'kennethCodesAllDay',
joinDate: 'March 26, 2016',
organization: 'freeCodeCamp',
friends: [
'Sam',
'Kira',
'Tomo'
],
location: {
city: 'San Francisco',
state: 'CA',
country: 'USA'
}
}
};
function addFriend(userObj, friend) {
// change code below this line
// change code above this line
}
console.log(addFriend(user, 'Pete'));
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,68 @@
---
id: 587d7b7c367417b2b2512b19
title: Modify an Object Nested Within an Object
challengeType: 1
videoUrl: ''
localeTitle: تعديل كائن متداخل داخل كائن
---
## Description
<section id="description"> الآن دعونا نلقي نظرة على كائن أكثر تعقيدا قليلا. يمكن أن تتداخل خصائص الكائن مع عمق اعتباطي ، ويمكن أن تكون قيمها أي نوع من البيانات التي تدعمها JavaScript ، بما في ذلك المصفوفات وحتى الكائنات الأخرى. خذ بعين الاعتبار ما يلي: <blockquote style=";text-align:right;direction:rtl"> let nestedObject = { <br> id: 28802695164 ، <br> التاريخ: &quot;31 ديسمبر 2016&quot; ، <br> البيانات: { <br> totalUsers: 99 ، <br> على الانترنت: 80 ، <br> الموجودين: { <br> نشط: 67 ، <br> بعيدا: 13 <br> } <br> } <br></blockquote> يحتوي <code>nestedObject</code> على ثلاثة مفاتيح فريدة: <code>id</code> ، قيمته عبارة عن رقم <code>date</code> قيمته عبارة عن سلسلة <code>data</code> ، تكون قيمتها عبارة عن كائن يحتوي على كائن آخر متداخل داخله. في حين أن الهياكل يمكن أن تصبح معقدة بسرعة ، إلا أنه لا يزال بإمكاننا استخدام نفس الرموز للوصول إلى المعلومات التي نحتاج إليها. </section>
## Instructions
<section id="instructions"> هنا قمنا بتعريف كائن ، <code>userActivity</code> ، والذي يتضمن كائنًا آخرًا متداخلاً فيه. يمكنك تعديل الخصائص على هذا الكائن المتداخل بنفس الطريقة التي قمت بتعديل الخصائص في التحدي الأخير. قم بتعيين قيمة المفتاح <code>online</code> على <code>45</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: لدى <code>userActivity</code> <code>id</code> <code>date</code> <code>data</code>
testString: 'assert("id" in userActivity && "date" in userActivity && "data" in userActivity, "<code>userActivity</code> has <code>id</code>, <code>date</code> and <code>data</code> properties");'
- text: لدى <code>userActivity</code> مفتاح <code>data</code> ضبطه على كائن به مفاتيح <code>totalUsers</code> وعبر <code>online</code>
testString: 'assert("totalUsers" in userActivity.data && "online" in userActivity.data, "<code>userActivity</code> has a <code>data</code> key set to an object with keys <code>totalUsers</code> and <code>online</code>");'
- text: يجب تعيين الخاصية <code>online</code> المتداخلة في مفتاح <code>data</code> <code>userActivity</code> على <code>45</code>
testString: 'assert(userActivity.data.online === 45, "The <code>online</code> property nested in the <code>data</code> key of <code>userActivity</code> should be set to <code>45</code>");'
- text: يتم تعيين الخاصية <code>online</code> باستخدام تدوين النقطة أو القوس
testString: 'assert.strictEqual(code.search(/online: 45/), -1, "The <code>online</code> property is set using dot or bracket notation");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
let userActivity = {
id: 23894201352,
date: 'January 1, 2017',
data: {
totalUsers: 51,
online: 42
}
};
// change code below this line
// change code above this line
console.log(userActivity);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,60 @@
---
id: 587d78b2367417b2b2512b0f
title: Remove Items from an Array with pop() and shift()
challengeType: 1
videoUrl: ''
localeTitle: إزالة العناصر من صفيف مع pop () و shift ()
---
## Description
<section id="description"> كل من <code>push()</code> و <code>unshift()</code> لهما <code>unshift()</code> : <code>pop()</code> و <code>shift()</code> . كما قد تكون قد خمنت الآن ، بدلاً من إضافة ، <em>يزيل</em> <code>pop()</code> عنصرًا من نهاية صفيف ، بينما يزيل <code>shift()</code> عنصرًا من البداية. الاختلاف الرئيسي بين <code>pop()</code> و <code>shift()</code> وأبناء عمومتهم <code>push()</code> و <code>unshift()</code> ، هو أن كلا الأسلوبين لا <code>unshift()</code> معلمات ، وكل منهما يسمح فقط بتعديل مصفوفة بواسطة عنصر واحد في كل مرة. لنلقي نظرة: <blockquote style=";text-align:right;direction:rtl"> اسمحوا تحيات = [ماذا يكون ما يصل؟ ، &#39;مرحبا&#39; ، &#39;انظر يا!&#39;] ؛ <br><br> greetings.pop ()؛ <br> // الآن تساوي [&#39;ما الأمر؟&#39; ، &#39;مرحبا&#39;] <br><br> greetings.shift ()؛ <br> // الآن تساوي [&#39;مرحبا&#39;] </blockquote> يمكننا أيضًا إرجاع قيمة العنصر الذي تمت إزالته باستخدام أي من الطريقتين التاليتين: <blockquote style=";text-align:right;direction:rtl"> دعونا برزت = تحيات. pop () ؛ <br> // إرجاع &quot;مرحبًا&quot; <br> // تحيات الآن تساوي [] </blockquote></section>
## Instructions
<section id="instructions"> لقد حددنا وظيفة ، <code>popShift</code> ، والتي تأخذ مصفوفة كوسيطة وترجع مصفوفة جديدة. قم بتعديل الوظيفة ، باستخدام <code>pop()</code> و <code>shift()</code> ، لإزالة العناصر الأولى والأخيرة لصفيف الوسيطة ، وتعيين العناصر التي تم إزالتها للمتغيرات الخاصة بها ، بحيث يحتوي الصفيف الذي تم إرجاعه على قيمها. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: '<code>popShift([&quot;challenge&quot;, &quot;is&quot;, &quot;not&quot;, &quot;complete&quot;])</code> يجب أن يعيد <code>[&quot;challenge&quot;, &quot;complete&quot;]</code>'
testString: 'assert.deepEqual(popShift(["challenge", "is", "not", "complete"]), ["challenge", "complete"], "<code>popShift(["challenge", "is", "not", "complete"])</code> should return <code>["challenge", "complete"]</code>");'
- text: يجب أن تستخدم وظيفة <code>popShift</code> الأسلوب <code>pop()</code>
testString: 'assert.notStrictEqual(popShift.toString().search(/\.pop\(/), -1, "The <code>popShift</code> function should utilize the <code>pop()</code> method");'
- text: يجب أن تستخدم وظيفة <code>popShift</code> طريقة <code>shift()</code>
testString: 'assert.notStrictEqual(popShift.toString().search(/\.shift\(/), -1, "The <code>popShift</code> function should utilize the <code>shift()</code> method");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function popShift(arr) {
let popped; // change this line
let shifted; // change this line
return [shifted, popped];
}
// do not change code below this line
console.log(popShift(['challenge', 'is', 'not', 'complete']));
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,59 @@
---
id: 587d78b2367417b2b2512b10
title: Remove Items Using splice()
challengeType: 1
videoUrl: ''
localeTitle: إزالة العناصر باستخدام لصق ()
---
## Description
<section id="description"> حسنًا ، لقد تعلمنا كيفية إزالة عناصر من بداية ونهاية المصفوفات باستخدام <code>shift()</code> و <code>pop()</code> ، ولكن ماذا لو أردنا إزالة عنصر من مكان ما في المنتصف؟ أو إزالة أكثر من عنصر واحد في وقت واحد؟ حسنا ، هذا هو المكان الذي تأتي فيه <code>splice()</code> . يسمح لنا <code>splice()</code> بالقيام بذلك: <strong>إزالة أي عدد من العناصر المتتالية</strong> من أي مكان في صفيف. يمكن أن تأخذ <code>splice()</code> 3 معلمات ، ولكن في الوقت الحالي ، سنركز على أول 2 فقط. <code>splice()</code> من <code>splice()</code> هي أعداد صحيحة تمثل الفهارس ، أو المواضع ، للصفيف الذي يكون <code>splice()</code> دعا. وتذكر أن المصفوفات <em>صفرية المفهرسة</em> ، لذلك للإشارة إلى العنصر الأول من المصفوفة ، سنستخدم <code>0</code> . تمثل المعلمة الأولى <code>splice()</code> الفهرس الموجود في الصفيف الذي تبدأ منه إزالة العناصر ، بينما تشير المعلمة الثانية إلى عدد العناصر المطلوب حذفها. فمثلا: <blockquote style=";text-align:right;direction:rtl"> دعونا صفيف = [&#39;اليوم&#39; ، &#39;كان&#39; ، &#39;لا&#39; ، &#39;هكذا&#39; ، &#39;عظيم&#39;] ؛ <br><br> array.splice (2، 2)؛ <br> // remove 2 elements starting with the 3rd element <br> // array الآن يساوي [&#39;today&#39;، &#39;was&#39;، &#39;great&#39;] </blockquote> <code>splice()</code> بتعديل المصفوفة التي يتم استدعاؤها فقط ، بل يقوم أيضًا بإرجاع صفيف جديد يحتوي على قيمة العناصر التي تمت إزالتها: <blockquote style=";text-align:right;direction:rtl"> دعونا صفيف = [&#39;أنا&#39; ، &#39;أنا&#39; ، &#39;شعور&#39; ، &#39;حقا&#39; ، &#39;سعيد&#39;] ؛ <br><br> السماح newArray = array.splice (3 ، 2) ؛ <br> // newArray يساوي [&#39;حقا&#39; ، &#39;سعيد&#39;] </blockquote></section>
## Instructions
<section id="instructions"> لقد قمنا بتعريف دالة ، <code>sumOfTen</code> ، والتي تأخذ مصفوفة كوسيطة وتقوم بإرجاع مجموع عناصر الصفيف. قم بتعديل الوظيفة ، باستخدام <code>splice()</code> ، بحيث تقوم بإرجاع قيمة <code>10</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>sumOfTen</code> 10
testString: 'assert.strictEqual(sumOfTen([2, 5, 1, 5, 2, 1]), 10, "<code>sumOfTen</code> should return 10");'
- text: يجب أن تستخدم الدالة <code>sumOfTen</code> الأسلوب <code>splice()</code>
testString: 'assert.notStrictEqual(sumOfTen.toString().search(/\.splice\(/), -1, "The <code>sumOfTen</code> function should utilize the <code>splice()</code> method");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function sumOfTen(arr) {
// change code below this line
// change code above this line
return arr.reduce((a, b) => a + b);
}
// do not change code below this line
console.log(sumOfTen([2, 5, 1, 5, 2, 1]));
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,57 @@
---
id: 587d7b7e367417b2b2512b20
title: Use an Array to Store a Collection of Data
challengeType: 1
videoUrl: ''
localeTitle: استخدم صفيف لتخزين مجموعة من البيانات
---
## Description
<section id="description"> أدناه هو مثال عن أبسط تنفيذ بنية بيانات صفيف. وهذا ما يُعرف باسم <dfn>مصفوفة أحادية البُعد</dfn> ، بمعنى أنه يحتوي على مستوى واحد فقط ، أو أنه لا يحتوي على أي صفيفات أخرى متداخلة فيه. لاحظ أنه يحتوي على وحدات <dfn>منطقية</dfn> ، <dfn>وسلاسل</dfn> ، <dfn>وأرقام</dfn> ، من بين أنواع بيانات جافا سكريبت صالحة أخرى: <blockquote style=";text-align:right;direction:rtl"> let simpleArray = [&#39;one&#39;، 2، &#39;three&#39;، true، false، undefined، null]؛ <br> console.log (simpleArray.length)؛ <br> // سجلات 7 </blockquote> جميع الصفيف لها خاصية طول ، والتي كما هو موضح أعلاه ، يمكن الوصول إليها بسهولة بالغة مع <code>Array.length</code> . يمكن رؤية تنفيذ أكثر تعقيدًا لمصفوفة أدناه. هذا هو المعروف باسم مجموعة <dfn>متعددة الأبعاد</dfn> ، أو صفيف يحتوي على صفائف أخرى. لاحظ أن هذه المصفوفة تحتوي أيضًا على <dfn>كائنات</dfn> JavaScript ، والتي سنبحثها عن كثب في قسمنا التالي ، ولكن في الوقت الحالي ، كل ما تحتاج إلى معرفته هو أن المصفوفات قادرة أيضًا على تخزين الكائنات المعقدة. <blockquote style=";text-align:right;direction:rtl"> اترك complexArray = [ <br> [ <br> { <br> واحد 1، <br> اثنان: 2 <br><br> { <br> 3: 3 ، <br> أربعة: 4 <br> } <br><br> [ <br> { <br> a: &quot;a&quot; ، <br> ب: &quot;ب&quot; <br><br> { <br> ج: &quot;ج&quot; ، <br> د: &quot;د&quot; <br> } <br> ] <br> ]. </blockquote></section>
## Instructions
<section id="instructions"> لقد حددنا متغيرًا يسمى <code>yourArray</code> . أكمل العبارة عن طريق تعيين صفيف مكون من خمسة عناصر على <code>yourArray</code> للمتغير <code>yourArray</code> . يجب أن يحتوي الصفيف الخاص بك على <dfn>سلسلة</dfn> واحدة على الأقل <dfn>ورقم</dfn> واحد <dfn>وقيمة منطقية</dfn> واحدة. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: yourArray هو مجموعة
testString: 'assert.strictEqual(Array.isArray(yourArray), true, "yourArray is an array");'
- text: <code>yourArray</code> ما لا يقل عن 5 عناصر طويلة
testString: 'assert.isAtLeast(yourArray.length, 5, "<code>yourArray</code> is at least 5 elements long");'
- text: <code>yourArray</code> يحتوي على <code>boolean</code> واحد على الأقل
testString: 'assert(yourArray.filter( el => typeof el === "boolean").length >= 1, "<code>yourArray</code> contains at least one <code>boolean</code>");'
- text: يحتوي <code>yourArray</code> على <code>number</code> واحد على الأقل
testString: 'assert(yourArray.filter( el => typeof el === "number").length >= 1, "<code>yourArray</code> contains at least one <code>number</code>");'
- text: يحتوي <code>yourArray</code> على <code>string</code> واحدة على الأقل
testString: 'assert(yourArray.filter( el => typeof el === "string").length >= 1, "<code>yourArray</code> contains at least one <code>string</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
let yourArray; // change this line
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,64 @@
---
id: 587d7b7c367417b2b2512b1b
title: Use the delete Keyword to Remove Object Properties
challengeType: 1
videoUrl: ''
localeTitle: استخدم Delete keyword to Remove Object Properties
---
## Description
<section id="description"> الآن أنت تعرف ما هي الأشياء وخصائصها ومزاياها الأساسية. باختصار، فهي مخازن المفاتيح ذات قيمة والتي توفر طريقة بديهية مرنة لتنظيم البيانات، <strong><em>و،</em></strong> لأنها توفر الوقت بحث سريع جدا. خلال بقية هذه التحديات ، سنقوم بوصف العديد من العمليات الشائعة التي يمكنك القيام بها على الكائنات بحيث يمكنك أن تصبح مريحًا في تطبيق هذه الهياكل المفيدة للبيانات في برامجك. في التحديات السابقة ، قمنا بإضافة وتعديل أزواج قيمة المفتاح للكائن. سنرى هنا كيف يمكننا <em>إزالة</em> زوج قيمة مفتاح من كائن. دعونا نعيد النظر في مثال كائن <code>foods</code> لدينا للمرة الأخيرة. إذا أردنا إزالة مفتاح <code>apples</code> ، فيمكننا إزالته باستخدام الكلمة الرئيسية التي <code>delete</code> مثل هذا: <blockquote style=";text-align:right;direction:rtl"> حذف foods.apples ؛ </blockquote></section>
## Instructions
<section id="instructions"> استخدم الكلمة الرئيسية حذف لإزالة <code>oranges</code> <code>plums</code> ومفاتيح <code>strawberries</code> من كائن <code>foods</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: 'يحتوي جسم <code>foods</code> على ثلاثة مفاتيح فقط: <code>apples</code> <code>grapes</code> <code>bananas</code>'
testString: 'assert(!foods.hasOwnProperty("oranges") && !foods.hasOwnProperty("plums") && !foods.hasOwnProperty("strawberries") && Object.keys(foods).length === 3, "The <code>foods</code> object only has three keys: <code>apples</code>, <code>grapes</code>, and <code>bananas</code>");'
- text: تتم إزالة مفاتيح <code>oranges</code> <code>plums</code> <code>strawberries</code> باستخدام <code>delete</code>
testString: 'assert(code.search(/oranges:/) !== -1 && code.search(/plums:/) !== -1 && code.search(/strawberries:/) !== -1, "The <code>oranges</code>, <code>plums</code>, and <code>strawberries</code> keys are removed using <code>delete</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
let foods = {
apples: 25,
oranges: 32,
plums: 28,
bananas: 13,
grapes: 35,
strawberries: 27
};
// change code below this line
// change code above this line
console.log(foods);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,67 @@
---
id: 56bbb991ad1ed5201cd392ca
title: Access Array Data with Indexes
challengeType: 1
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/access-array-data-with-indexes'
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert((function(){if(typeof myArray !== "undefined" && typeof myData !== "undefined" && myArray[0] === myData){return true;}else{return false;}})(), "The variable <code>myData</code> should equal the first value of <code>myArray</code>.");'
- text: يجب الوصول إلى البيانات في متغير <code>myArray</code> باستخدام تدوين قوس.
testString: 'assert((function(){if(code.match(/\s*=\s*myArray\[0\]/g)){return true;}else{return false;}})(), "The data in variable <code>myArray</code> should be accessed using bracket notation.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourArray = [50,60,70];
var ourData = ourArray[0]; // equals 50
// Setup
var myArray = [50,60,70];
// Only change code below this line.
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,64 @@
---
id: 56592a60ddddeae28f7aa8e1
title: Access Multi-Dimensional Arrays With Indexes
challengeType: 1
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/access-array-data-with-indexes'
videoUrl: ''
localeTitle: الوصول إلى صفائف متعددة الأبعاد مع فهارس
---
## Description
<section id="description"> طريقة واحدة للتفكير في مصفوفة <dfn>متعددة الأبعاد</dfn> ، هي بمثابة <em>صفيف من المصفوفات</em> . عند استخدام الأقواس للوصول إلى الصفيف الخاص بك ، تشير المجموعة الأولى من الأقواس إلى الإدخالات الموجودة في مصفوفة الجزء الخارجي (المستوى الأول) ، ويشير كل زوج إضافي من الأقواس إلى المستوى التالي من الإدخالات بالداخل. <strong>مثال</strong> <blockquote style=";text-align:right;direction:rtl"> var arr = [ <br> [1،2،3]، <br> [4،5،6]، <br> [7،8،9]، <br> [[10،11،12] ، 13 ، 14] <br> ]. <br> آر [3]. // يساوي [[10،11،12] ، 13 ، 14] <br> آر [3] [0]؛ // يساوي [10،11،12] <br> آر [3] [0] [1]؛ // يساوي 11 </blockquote> <strong>ملحوظة</strong> <br> يجب ألا يكون هناك أي مسافات بين اسم الصفيف والأقواس المربعة ، مثل <code>array [0][0]</code> وحتى هذا <code>array [0] [0]</code> غير مسموح به. على الرغم من أن JavaScript قادر على معالجة هذا بشكل صحيح ، فقد يؤدي ذلك إلى إرباك المبرمجين الآخرين في قراءة التعليمات البرمجية. </section>
## Instructions
<section id="instructions"> باستخدام <code>myArray</code> قوس حدد عنصر من <code>myArray</code> بحيث يكون <code>myData</code> يساوي <code>8</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن تساوي <code>myData</code> <code>8</code> .
testString: 'assert(myData === 8, "<code>myData</code> should be equal to <code>8</code>.");'
- text: يجب أن تستخدم تدوين قوس لقراءة القيمة الصحيحة من <code>myArray</code> .
testString: 'assert(/myArray\[2\]\[1\]/g.test(code) && !/myData\s*=\s*(?:.*[-+*/%]|\d)/g.test(code), "You should be using bracket notation to read the correct value from <code>myArray</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Setup
var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]];
// Only change code below this line.
var myData = myArray[0][0];
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,82 @@
---
id: 56533eb9ac21ba0edf2244cd
title: Accessing Nested Arrays
challengeType: 1
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/access-array-data-with-indexes'
videoUrl: ''
localeTitle: الوصول إلى صفائف متداخلة
---
## Description
<section id="description"> كما رأينا في الأمثلة السابقة ، يمكن أن تحتوي الكائنات على كل من الكائنات المتداخلة والصفائف المتداخلة. على غرار الوصول إلى الكائنات المتداخلة ، يمكن تقييد تدرج قوس Array للوصول إلى صفائف متداخلة. فيما يلي مثال لكيفية الوصول إلى صفيف متداخل: <blockquote style=";text-align:right;direction:rtl"> var ourPets = [ <br> { <br> animalType: &quot;قطة&quot; ، <br> الأسماء: [ <br> &quot;Meowzer&quot; <br> &quot;رقيق&quot;، <br> &quot;كيت كات&quot; <br> ] <br><br> { <br> animalType: &quot;dog&quot; ، <br> الأسماء: [ <br> &quot;بقعة&quot;، <br> &quot;العربة&quot;، <br> &quot;فرانكي&quot; <br> ] <br> } <br> ]. <br> ourPets [0] .names [1]؛ // &quot;رقيق&quot; <br> ourPets [1] .names [0]؛ // &quot;سبوت&quot; </blockquote></section>
## Instructions
<section id="instructions"> استرجاع الشجرة الثانية من <code>myPlants</code> المتغير باستخدام <code>myPlants</code> نقطة الكائن <code>myPlants</code> مجموعة الصفيف. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>secondTree</code> ينبغي أن يساوي &quot;الصنوبر&quot;
testString: 'assert(secondTree === "pine", "<code>secondTree</code> should equal "pine"");'
- text: استخدم نقطة <code>myPlants</code> قوس للوصول إلى <code>myPlants</code>
testString: 'assert(/=\s*myPlants\[1\].list\[1\]/.test(code), "Use dot and bracket notation to access <code>myPlants</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Setup
var myPlants = [
{
type: "flowers",
list: [
"rose",
"tulip",
"dandelion"
]
},
{
type: "trees",
list: [
"fir",
"pine",
"birch"
]
}
];
// Only change code below this line
var secondTree = ""; // Change this line
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,73 @@
---
id: 56533eb9ac21ba0edf2244cc
title: Accessing Nested Objects
challengeType: 1
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/accessing-nested-objects-in-json'
videoUrl: ''
localeTitle: الوصول إلى الكائنات المتداخلة
---
## Description
<section id="description"> يمكن الوصول إلى الخصائص الفرعية للكائنات عن طريق ربط صيغة النقطة أو القوس. هنا كائن متداخل: <blockquote style=";text-align:right;direction:rtl"> var ourStorage = { <br> &quot;مكتب&quot;: { <br> &quot;الدرج&quot;: &quot;دباسة&quot; <br><br> &quot;خزانة&quot;: { <br> &quot;الدرج العلوي&quot;: { <br> &quot;folder1&quot;: &quot;ملف&quot; ، <br> &quot;folder2&quot;: &quot;secrets&quot; <br><br> &quot;درج سفلي&quot;: &quot;الصودا&quot; <br> } <br><br> ourStorage.cabinet [&quot;top drawer&quot;]. // &quot;أسرار&quot; <br> ourStorage.desk.drawer. // &quot;دباسة&quot; </blockquote></section>
## Instructions
<section id="instructions"> قم بالوصول إلى كائن <code>myStorage</code> وقم بتعيين محتويات خاصية <code>glove box</code> إلى متغير <code>gloveBoxContents</code> . استخدام تدرج قوس للمواقع مع مساحة في أسمائهم. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن يساوي <code>gloveBoxContents</code> &quot;الخرائط&quot;
testString: 'assert(gloveBoxContents === "maps", "<code>gloveBoxContents</code> should equal "maps"");'
- text: استخدم تدوين النقطة <code>myStorage</code> للوصول إلى <code>myStorage</code>
testString: 'assert(/=\s*myStorage\.car\.inside\[\s*("|")glove box\1\s*\]/g.test(code), "Use dot and bracket notation to access <code>myStorage</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Setup
var myStorage = {
"car": {
"inside": {
"glove box": "maps",
"passenger seat": "crumbs"
},
"outside": {
"trunk": "jack"
}
}
};
var gloveBoxContents = undefined; // Change this line
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,76 @@
---
id: 56533eb9ac21ba0edf2244c8
title: Accessing Object Properties with Bracket Notation
challengeType: 1
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/accessing-objects-properties-with-bracket-notation'
videoUrl: ''
localeTitle: الوصول إلى خصائص كائن مع تدرج قوس
---
## Description
<section id="description"> الطريقة الثانية للوصول إلى خصائص كائن تدوين قوس ( <code>[]</code> ). إذا كانت خاصية الكائن الذي تحاول الوصول إليه تحتوي على مسافة في اسمه ، فستحتاج إلى استخدام تدرج قوس. ومع ذلك ، لا يزال بإمكانك استخدام تدرج قوس على خصائص الكائن بدون مسافات. هنا عينة من استخدام تدرج قوس لقراءة خاصية الكائن: <blockquote style=";text-align:right;direction:rtl"> var myObj = { <br> &quot;اسم الفضاء&quot;: &quot;كيرك&quot; ، <br> &quot;مساحة إضافية&quot;: &quot;سبوك&quot; ، <br> &quot;NoSpace&quot;: &quot;USS Enterprise&quot; <br><br> myObj [&quot;اسم الفضاء&quot;] ؛ // كيرك <br> myObj [&#39;More Space&#39;]؛ // سبوك <br> myObj [ &quot;NoSpace&quot;]؛ // يو اس اس انتربرايز </blockquote> لاحظ أن أسماء الخصائص التي تحتوي على مسافات يجب أن تكون بين علامتي اقتباس (مفرد أو مزدوج). </section>
## Instructions
<section id="instructions"> قراءة قيم خصائص <code>&quot;an entree&quot;</code> و <code>&quot;the drink&quot;</code> من <code>testObj</code> باستخدام تدوين قوس <code>entreeValue</code> إلى <code>entreeValue</code> <code>drinkValue</code> على التوالي. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن يكون <code>entreeValue</code> عبارة عن سلسلة
testString: 'assert(typeof entreeValue === "string" , "<code>entreeValue</code> should be a string");'
- text: يجب أن تكون قيمة <code>entreeValue</code> <code>&quot;hamburger&quot;</code>
testString: 'assert(entreeValue === "hamburger" , "The value of <code>entreeValue</code> should be <code>"hamburger"</code>");'
- text: يجب أن يكون <code>drinkValue</code> سلسلة
testString: 'assert(typeof drinkValue === "string" , "<code>drinkValue</code> should be a string");'
- text: قيمة <code>drinkValue</code> يجب أن تكون <code>&quot;water&quot;</code>
testString: 'assert(drinkValue === "water" , "The value of <code>drinkValue</code> should be <code>"water"</code>");'
- text: يجب عليك استخدام تدوين قوس مرتين
testString: 'assert(code.match(/testObj\s*?\[("|")[^""]+\1\]/g).length > 1, "You should use bracket notation twice");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Setup
var testObj = {
"an entree": "hamburger",
"my side": "veggies",
"the drink": "water"
};
// Only change code below this line
var entreeValue = testObj; // Change this line
var drinkValue = testObj; // Change this line
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,75 @@
---
id: 56533eb9ac21ba0edf2244c7
title: Accessing Object Properties with Dot Notation
challengeType: 1
videoUrl: ''
localeTitle: الوصول إلى خصائص كائن مع ترميز Dot
---
## Description
<section id="description"> هناك طريقتان للوصول إلى خصائص كائن: تدوين نقطي ( <code>.</code> ) وتدوين قوس ( <code>[]</code> ) ، شبيه بصفيف. Dot notation هو ما تستخدمه عندما تعرف اسم العقار الذي تحاول الوصول إليه في وقت مبكر. هنا عينة من استخدام تدوين النقطة ( <code>.</code> ) لقراءة خاصية الكائن: <blockquote style=";text-align:right;direction:rtl"> var myObj = { <br> prop1: &quot;val1&quot; ، <br> prop2: &quot;val2&quot; <br><br> var prop1val = myObj.prop1 ، // val1 <br> var prop2val = myObj.prop2؛ // val2 </blockquote></section>
## Instructions
<section id="instructions"> قراءة في قيم خاصية <code>testObj</code> باستخدام التدوين النقطي. تعيين <code>hatValue</code> متغير يساوي <code>hat</code> خاصية الكائن وتعيين <code>shirtValue</code> متغير <code>shirtValue</code> يساوي <code>shirt</code> خاصية الكائن. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن يكون <code>hatValue</code> سلسلة
testString: 'assert(typeof hatValue === "string" , "<code>hatValue</code> should be a string");'
- text: قيمة <code>hatValue</code> يجب أن تكون <code>&quot;ballcap&quot;</code>
testString: 'assert(hatValue === "ballcap" , "The value of <code>hatValue</code> should be <code>"ballcap"</code>");'
- text: يجب أن يكون <code>shirtValue</code> عبارة عن سلسلة
testString: 'assert(typeof shirtValue === "string" , "<code>shirtValue</code> should be a string");'
- text: يجب أن تكون قيمة <code>shirtValue</code> <code>&quot;jersey&quot;</code>
testString: 'assert(shirtValue === "jersey" , "The value of <code>shirtValue</code> should be <code>"jersey"</code>");'
- text: يجب عليك استخدام dot notation مرتين
testString: 'assert(code.match(/testObj\.\w+/g).length > 1, "You should use dot notation twice");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Setup
var testObj = {
"hat": "ballcap",
"shirt": "jersey",
"shoes": "cleats"
};
// Only change code below this line
var hatValue = testObj; // Change this line
var shirtValue = testObj; // Change this line
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,78 @@
---
id: 56533eb9ac21ba0edf2244c9
title: Accessing Object Properties with Variables
challengeType: 1
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/accessing-objects-properties-with-variables'
videoUrl: ''
localeTitle: الوصول إلى خصائص الكائن مع المتغيرات
---
## Description
<section id="description"> استخدام آخر لتدوين قوس على الكائنات هو الوصول إلى خاصية يتم تخزينها كقيمة متغير. يمكن أن يكون هذا مفيدًا جدًا للتكرار من خلال خصائص الكائن أو عند الوصول إلى جدول البحث. في ما يلي مثال على استخدام متغير للوصول إلى موقع: <blockquote style=";text-align:right;direction:rtl"> var dogs = { <br> Fido: &quot;Mutt&quot;، Hunter: &quot;Doberman&quot;، Snoopie: &quot;Beagle&quot; <br><br> var myDog = &quot;Hunter&quot; ؛ <br> var myBreed = dogs [myDog]؛ <br> console.log (myBreed)؛ // &quot;دوبيرمان&quot; </blockquote> هناك طريقة أخرى لاستخدام هذا المفهوم وهي عندما يتم جمع اسم المنشأة ديناميكيًا أثناء تنفيذ البرنامج ، كما يلي: <blockquote style=";text-align:right;direction:rtl"> var someObj = { <br> propName: &quot;John&quot; <br><br> وظيفة propPrefix (str) { <br> var s = &quot;prop&quot; ؛ <br> return s + str؛ <br> } <br> var someProp = propPrefix (&quot;Name&quot;)؛ // someProp الآن يحمل القيمة &quot;propName&quot; <br> console.log (someObj [someProp])؛ // &quot;يوحنا&quot; </blockquote> لاحظ أننا <em>لا</em> نستخدم علامات اقتباس حول اسم المتغير عند استخدامه للوصول إلى الخاصية لأننا نستخدم <em>قيمة</em> المتغير ، وليس <em>الاسم</em> . </section>
## Instructions
<section id="instructions"> استخدم متغير <code>playerNumber</code> للبحث عن المشغل <code>16</code> في <code>testObj</code> باستخدام <code>testObj</code> قوس. ثم قم بتعيين هذا الاسم إلى متغير <code>player</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن يكون <code>playerNumber</code> رقمًا
testString: 'assert(typeof playerNumber === "number", "<code>playerNumber</code> should be a number");'
- text: يجب أن يكون <code>player</code> المتغير عبارة عن سلسلة
testString: 'assert(typeof player === "string", "The variable <code>player</code> should be a string");'
- text: يجب أن تكون قيمة <code>player</code> &quot;مونتانا&quot;
testString: 'assert(player === "Montana", "The value of <code>player</code> should be "Montana"");'
- text: يجب عليك استخدام تدوين قوس للوصول إلى <code>testObj</code>
testString: 'assert(/testObj\s*?\[.*?\]/.test(code),"You should use bracket notation to access <code>testObj</code>");'
- text: يجب عدم تعيين قيمة <code>Montana</code> إلى <code>player</code> المتغير مباشرةً.
testString: 'assert(!code.match(/player\s*=\s*"|\"\s*Montana\s*"|\"\s*;/gi),"You should not assign the value <code>Montana</code> to the variable <code>player</code> directly.");'
- text: يجب أن تستخدم المتغير <code>playerNumber</code> في تدوين <code>playerNumber</code>
testString: 'assert(/testObj\s*?\[\s*playerNumber\s*\]/.test(code),"You should be using the variable <code>playerNumber</code> in your bracket notation");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Setup
var testObj = {
12: "Namath",
16: "Montana",
19: "Unitas"
};
// Only change code below this line;
var playerNumber; // Change this Line
var player = testObj; // Change this Line
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,77 @@
---
id: 56bbb991ad1ed5201cd392d2
title: Add New Properties to a JavaScript Object
challengeType: 1
videoUrl: ''
localeTitle: أضف خصائص جديدة إلى كائن JavaScript
---
## Description
<section id="description"> يمكنك إضافة خصائص جديدة إلى كائنات JavaScript الموجودة بالطريقة نفسها التي يمكنك تعديلها بها. في ما يلي كيفية إضافة خاصية <code>&quot;bark&quot;</code> إلى <code>ourDog</code> : <code>ourDog.bark = &quot;bow-wow&quot;;</code> أو <code>ourDog[&quot;bark&quot;] = &quot;bow-wow&quot;;</code> الآن عندما نقيم <code>ourDog.bark</code> ، <code>ourDog.bark</code> ، &quot;bow-wow&quot;. </section>
## Instructions
<section id="instructions"> إضافة خاصية <code>&quot;bark&quot;</code> إلى <code>myDog</code> وتعيينه إلى صوت كلب ، مثل &quot;woof&quot;. يمكنك استخدام أي نقطة أو تدوين قوس. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: إضافة <code>&quot;bark&quot;</code> الملكية إلى <code>myDog</code> .
testString: 'assert(myDog.bark !== undefined, "Add the property <code>"bark"</code> to <code>myDog</code>.");'
- text: لا تضف <code>&quot;bark&quot;</code> إلى قسم الإعداد
testString: 'assert(!/bark[^\n]:/.test(code), "Do not add <code>"bark"</code> to the setup section");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourDog = {
"name": "Camper",
"legs": 4,
"tails": 1,
"friends": ["everything!"]
};
ourDog.bark = "bow-wow";
// Setup
var myDog = {
"name": "Happy Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"]
};
// Only change code below this line.
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,59 @@
---
id: cf1111c1c11feddfaeb3bdef
title: Add Two Numbers with JavaScript
challengeType: 1
videoUrl: ''
localeTitle: أضف رقمين مع JavaScript
---
## Description
<section id="description"> <code>Number</code> هو نوع البيانات في JavaScript والذي يمثل البيانات الرقمية. الآن دعنا نحاول إضافة رقمين باستخدام JavaScript. تستخدم JavaScript الرمز <code>+</code> كعملية إضافة عند وضعها بين رقمين. <strong>مثال</strong> <blockquote style=";text-align:right;direction:rtl"> myVar = 5 + 10؛ // المعين 15 </blockquote></section>
## Instructions
<section id="instructions"> تغيير <code>0</code> بحيث يساوي مجموع <code>20</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>sum</code> يجب أن يساوي <code>20</code>
testString: 'assert(sum === 20, "<code>sum</code> should equal <code>20</code>");'
- text: استخدم عامل التشغيل <code>+</code>
testString: 'assert(/\+/.test(code), "Use the <code>+</code> operator");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var sum = 10 + 0;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,75 @@
---
id: 56533eb9ac21ba0edf2244de
title: Adding a Default Option in Switch Statements
challengeType: 1
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/adding-a-default-option-in-switch-statements'
videoUrl: ''
localeTitle: إضافة خيار افتراضي في تبديل البيانات
---
## Description
<section id="description"> في بيان <code>switch</code> قد لا تتمكن من تحديد جميع القيم المحتملة كبيانات <code>case</code> . بدلاً من ذلك ، يمكنك إضافة العبارة <code>default</code> التي سيتم تنفيذها في حالة عدم العثور على عبارات <code>case</code> مطابقة. أعتقد أنه من مثل النهائي <code>else</code> بيان في <code>if/else</code> السلسلة. يجب أن تكون العبارة <code>default</code> هي الحالة الأخيرة. <blockquote style=";text-align:right;direction:rtl"> التبديل (عدد) { <br> قيمة الحالة 1: <br> statement1. <br> استراحة؛ <br> قيمة الحالة 2: <br> statement2. <br> استراحة؛ <br> ... <br> الافتراضي: <br> defaultStatement. <br> استراحة؛ <br> } </blockquote></section>
## Instructions
<section id="instructions"> اكتب عبارة تبديل لتعيين <code>answer</code> عن الشروط التالية: <br> <code>&quot;a&quot;</code> - &quot;apple&quot; <br> <code>&quot;b&quot;</code> - &quot;طائر&quot; <br> <code>&quot;c&quot;</code> - &quot;cat&quot; <br> <code>default</code> - &quot;الاشياء&quot; </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن يكون لـ <code>switchOfStuff(&quot;a&quot;)</code> قيمة &quot;apple&quot;
testString: 'assert(switchOfStuff("a") === "apple", "<code>switchOfStuff("a")</code> should have a value of "apple"");'
- text: يجب أن يكون <code>switchOfStuff(&quot;b&quot;)</code> قيمة &quot;bird&quot;
testString: 'assert(switchOfStuff("b") === "bird", "<code>switchOfStuff("b")</code> should have a value of "bird"");'
- text: يجب أن يكون لـ <code>switchOfStuff(&quot;c&quot;)</code> قيمة &quot;cat&quot;
testString: 'assert(switchOfStuff("c") === "cat", "<code>switchOfStuff("c")</code> should have a value of "cat"");'
- text: يجب أن يكون لـ <code>switchOfStuff(&quot;d&quot;)</code> قيمة &quot;الأشياء&quot;
testString: 'assert(switchOfStuff("d") === "stuff", "<code>switchOfStuff("d")</code> should have a value of "stuff"");'
- text: يجب أن يكون <code>switchOfStuff(4)</code> قيمة &quot;الأشياء&quot;
testString: 'assert(switchOfStuff(4) === "stuff", "<code>switchOfStuff(4)</code> should have a value of "stuff"");'
- text: يجب عدم استخدام أي <code>if</code> أو <code>else</code> البيانات
testString: 'assert(!/else/g.test(code) || !/if/g.test(code), "You should not use any <code>if</code> or <code>else</code> statements");'
- text: يجب عليك استخدام العبارة <code>default</code>
testString: 'assert(switchOfStuff("string-to-trigger-default-case") === "stuff", "You should use a <code>default</code> statement");'
- text: يجب أن يكون لديك على الأقل 3 بيانات <code>break</code>
testString: 'assert(code.match(/break/g).length > 2, "You should have at least 3 <code>break</code> statements");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function switchOfStuff(val) {
var answer = "";
// Only change code below this line
// Only change code above this line
return answer;
}
// Change this value to test
switchOfStuff(1);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,68 @@
---
id: 56533eb9ac21ba0edf2244ed
title: Appending Variables to Strings
challengeType: 1
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/appending-variables-to-strings'
videoUrl: ''
localeTitle: إلحاق المتغيرات بالسلاسل
---
## Description
<section id="description"> مثلما يمكننا بناء سلسلة على عدة أسطر من <dfn>القيم الحرفية</dfn> ، يمكننا أيضًا إضافة متغيرات إلى سلسلة باستخدام عامل plus equals ( <code>+=</code> ). </section>
## Instructions
<section id="instructions"> <code>someAdjective</code> إلى <code>myStr</code> باستخدام <code>+=</code> عامل التشغيل. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>someAdjective</code> يجب تعيين إلى سلسلة 3 أحرف على الأقل طويلة
testString: 'assert(typeof someAdjective !== "undefined" && someAdjective.length > 2, "<code>someAdjective</code> should be set to a string at least 3 characters long");'
- text: إلحاق <code>someAdjective</code> إلى <code>myStr</code> باستخدام <code>+=</code> عامل التشغيل
testString: 'assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0, "Append <code>someAdjective</code> to <code>myStr</code> using the <code>+=</code> operator");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var anAdjective = "awesome!";
var ourStr = "freeCodeCamp is ";
ourStr += anAdjective;
// Only change code below this line
var someAdjective;
var myStr = "Learning to code is ";
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,76 @@
---
id: 56533eb9ac21ba0edf2244c3
title: Assignment with a Returned Value
challengeType: 1
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/assignment-with-a-returned-value'
videoUrl: ''
localeTitle: التنازل مع القيمة المرتجعة
---
## Description
<section id="description"> إذا كنت ستتذكر من مناقشتنا لـ <a href="javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator" target="_blank">Storing Values ​​مع Assignment Operator</a> ، يتم حل كل شيء على يمين علامة المساواة قبل تعيين القيمة. هذا يعني أنه يمكننا أخذ قيمة الإرجاع للدالة وتعيينها لمتغير. افترض أننا حددنا مسبقا <code>sum</code> وظيفة يضيف رقمين معا ، ثم: <code>ourSum = sum(5, 12);</code> سوف تستدعي دالة <code>sum</code> ، والتي تُرجع قيمة <code>17</code> <code>ourSum</code> المتغير. </section>
## Instructions
<section id="instructions"> استدعاء الدالة <code>processArg</code> مع وسيطة من <code>7</code> وتعيين قيمته الإرجاع إلى المتغير <code>processed</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>processed</code> يجب أن يكون لها قيمة <code>2</code>
testString: 'assert(processed === 2, "<code>processed</code> should have a value of <code>2</code>");'
- text: يجب عليك تعيين <code>processArg</code> <code>processed</code>
testString: 'assert(/processed\s*=\s*processArg\(\s*7\s*\)\s*;/.test(code), "You should assign <code>processArg</code> to <code>processed</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var changed = 0;
function change(num) {
return (num + 5) / 3;
}
changed = change(10);
// Setup
var processed = 0;
function processArg(num) {
return (num + 3) / 5;
}
// Only change code below this line
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,80 @@
---
id: 56bbb991ad1ed5201cd392d0
title: Build JavaScript Objects
challengeType: 1
videoUrl: ''
localeTitle: بناء كائنات جافا سكريبت
---
## Description
<section id="description"> ربما سمعت المصطلح <code>object</code> قبل. تشبه الكائنات <code>arrays</code> ، إلا أنه بدلاً من استخدام الفهارس للوصول إلى بياناتها وتعديلها ، يمكنك الوصول إلى البيانات الموجودة في الكائنات من خلال ما يسمى <code>properties</code> . تُعد الكائنات مفيدة لتخزين البيانات بطريقة منظمة ، ويمكن أن تمثل كائنات العالم الحقيقي ، مثل القطة. وإليك عينة كائن القط: <blockquote style=";text-align:right;direction:rtl"> var cat = { <br> &quot;الاسم&quot;: &quot;الشعيرات&quot; ، <br> &quot;الساقين&quot;: 4 ، <br> &quot;ذيول&quot;: 1 ، <br> &quot;الأعداء&quot;: [&quot;Water&quot;، &quot;Dogs&quot;] <br></blockquote> في هذا المثال ، يتم تخزين جميع الخصائص كسلاسل ، مثل - <code>&quot;name&quot;</code> ، <code>&quot;legs&quot;</code> ، و <code>&quot;tails&quot;</code> . ومع ذلك ، يمكنك أيضًا استخدام الأرقام كخصائص. يمكنك حتى حذف علامات الاقتباس لخصائص السلسلة المفردة الكلمة ، كما يلي: <blockquote style=";text-align:right;direction:rtl"> var anotherObject = { <br> جعل: &quot;فورد&quot; ، <br> 5: &quot;خمسة&quot; ، <br> &quot;نموذج&quot;: &quot;التركيز&quot; <br></blockquote> ومع ذلك ، إذا كان الكائن الخاص بك يحتوي على أية خصائص غير سلسلة ، فسوف يقوم جافا سكريبت بتلبيسها تلقائيًا كسلاسل. </section>
## Instructions
<section id="instructions"> جعل كائن يمثل كلب يسمى <code>myDog</code> الذي يحتوي على خصائص <code>&quot;name&quot;</code> (سلسلة) ، <code>&quot;legs&quot;</code> ، <code>&quot;tails&quot;</code> و <code>&quot;friends&quot;</code> . يمكنك تعيين خصائص الكائن هذه إلى أي قيم تريدها ، حيث أن <code>&quot;name&quot;</code> الطويل عبارة عن سلسلة ، و <code>&quot;legs&quot;</code> و <code>&quot;tails&quot;</code> هي أرقام ، و <code>&quot;friends&quot;</code> هو مصفوفة. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>myDog</code> يجب أن يحتوي على <code>name</code> الخاصية ويجب أن يكون <code>string</code> .
testString: 'assert((function(z){if(z.hasOwnProperty("name") && z.name !== undefined && typeof z.name === "string"){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>name</code> and it should be a <code>string</code>.");'
- text: <code>myDog</code> يجب أن يحتوي على <code>legs</code> العقار ويجب أن يكون <code>number</code> .
testString: 'assert((function(z){if(z.hasOwnProperty("legs") && z.legs !== undefined && typeof z.legs === "number"){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>legs</code> and it should be a <code>number</code>.");'
- text: <code>myDog</code> يجب أن يحتوي على <code>tails</code> الخاصية ويجب أن يكون <code>number</code> .
testString: 'assert((function(z){if(z.hasOwnProperty("tails") && z.tails !== undefined && typeof z.tails === "number"){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>tails</code> and it should be a <code>number</code>.");'
- text: <code>myDog</code> يجب أن يحتوي على <code>friends</code> الملكية ويجب أن يكون <code>array</code> .
testString: 'assert((function(z){if(z.hasOwnProperty("friends") && z.friends !== undefined && Array.isArray(z.friends)){return true;}else{return false;}})(myDog), "<code>myDog</code> should contain the property <code>friends</code> and it should be an <code>array</code>.");'
- text: يجب أن يحتوي <code>myDog</code> على جميع الخصائص المحددة فقط.
testString: 'assert((function(z){return Object.keys(z).length === 4;})(myDog), "<code>myDog</code> should only contain all the given properties.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourDog = {
"name": "Camper",
"legs": 4,
"tails": 1,
"friends": ["everything!"]
};
// Only change code below this line.
var myDog = {
};
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,82 @@
---
id: 56533eb9ac21ba0edf2244dc
title: Chaining If Else Statements
challengeType: 1
videoUrl: ''
localeTitle: تسلسل إذا كانت تصريحات أخرى
---
## Description
<section id="description"> <code>if/else</code> يمكن ربط عبارات <code>if/else</code> معًا لمنطق معقد. هنا هو <dfn>pseudocode</dfn> متعددة متعددة السلاسل <code>if</code> / <code>else if</code> العبارات: <blockquote style=";text-align:right;direction:rtl"> إذا ( <em>condition1</em> ) { <br> <em>statement1</em> <br> } آخر إذا ( <em>condition2</em> ) { <br> <em>statement2</em> <br> } آخر إذا ( <em>condition3</em> ) { <br> <em>statement3</em> <br> . . . <br> } آخر { <br> <em>statementN</em> <br> } </blockquote></section>
## Instructions
<section id="instructions"> كتابة مقيد <code>if</code> / <code>else if</code> عبارات تفي بالشروط التالية: <code>num &lt; 5</code> - return &quot;Tiny&quot; <br> <code>num &lt; 10</code> - عودة &quot;صغير&quot; <br> <code>num &lt; 15</code> - عودة &quot;متوسطة&quot; <br> <code>num &lt; 20</code> - عودة &quot;كبير&quot; <br> <code>num &gt;= 20</code> - return &quot;Huge&quot; </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن يكون لديك على الأقل أربع <code>else</code> البيانات
testString: 'assert(code.match(/else/g).length > 3, "You should have at least four <code>else</code> statements");'
- text: يجب أن يكون لديك أربعة على الأقل <code>if</code> البيانات
testString: 'assert(code.match(/if/g).length > 3, "You should have at least four <code>if</code> statements");'
- text: يجب أن يكون لديك بيان <code>return</code> واحد على الأقل
testString: 'assert(code.match(/return/g).length >= 1, "You should have at least one <code>return</code> statement");'
- text: يجب أن ترجع <code>testSize(0)</code> &quot;صغيرة&quot;
testString: 'assert(testSize(0) === "Tiny", "<code>testSize(0)</code> should return "Tiny"");'
- text: يجب أن ترجع <code>testSize(4)</code> &quot;صغيرة&quot;
testString: 'assert(testSize(4) === "Tiny", "<code>testSize(4)</code> should return "Tiny"");'
- text: <code>testSize(5)</code> إرجاع &quot;صغير&quot;
testString: 'assert(testSize(5) === "Small", "<code>testSize(5)</code> should return "Small"");'
- text: <code>testSize(8)</code> إرجاع &quot;صغير&quot;
testString: 'assert(testSize(8) === "Small", "<code>testSize(8)</code> should return "Small"");'
- text: <code>testSize(10)</code> إرجاع &quot;Medium&quot;
testString: 'assert(testSize(10) === "Medium", "<code>testSize(10)</code> should return "Medium"");'
- text: <code>testSize(14)</code> إرجاع &quot;Medium&quot;
testString: 'assert(testSize(14) === "Medium", "<code>testSize(14)</code> should return "Medium"");'
- text: <code>testSize(15)</code> إرجاع &quot;كبير&quot;
testString: 'assert(testSize(15) === "Large", "<code>testSize(15)</code> should return "Large"");'
- text: <code>testSize(17)</code> إرجاع &quot;كبير&quot;
testString: 'assert(testSize(17) === "Large", "<code>testSize(17)</code> should return "Large"");'
- text: <code>testSize(20)</code> إرجاع &quot;ضخم&quot;
testString: 'assert(testSize(20) === "Huge", "<code>testSize(20)</code> should return "Huge"");'
- text: <code>testSize(25)</code> إرجاع &quot;ضخم&quot;
testString: 'assert(testSize(25) === "Huge", "<code>testSize(25)</code> should return "Huge"");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function testSize(num) {
// Only change code below this line
return "Change Me";
// Only change code above this line
}
// Change this value to test
testSize(7);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,50 @@
---
id: bd7123c9c441eddfaeb4bdef
title: Comment Your JavaScript Code
challengeType: 1
videoUrl: ''
localeTitle: تعليق كود جافاسكريبت الخاص بك
---
## Description
<section id="description"> التعليقات هي أسطر من التعليمات البرمجية التي ستتجاهلها JavaScript بشكل مقصود. تعتبر التعليقات طريقة رائعة لترك ملاحظاتك لنفسك وللأشخاص الآخرين الذين سيحتاجون لاحقًا لمعرفة ما يفعله هذا الرمز. هناك طريقتان لكتابة التعليقات في جافا سكريبت: سيخبر استخدام <code>//</code> جافا سكريبت JavaScript لتجاهل الجزء المتبقي من النص في السطر الحالي: <blockquote style=";text-align:right;direction:rtl"> // هذا تعليق مباشر. </blockquote> يمكنك إنشاء تعليق متعدد الأسطر يبدأ بـ <code>/*</code> وينتهي بـ <code>*/</code> : <blockquote style=";text-align:right;direction:rtl"> /* هذا ال <br> تعليق متعدد الخطوط * / </blockquote> <strong>افضل تمرين</strong> <br> أثناء كتابة التعليمة البرمجية ، يجب إضافة التعليقات بانتظام لتوضيح وظيفة أجزاء من التعليمات البرمجية. يمكن للتعليق الجيد أن يساعد في توصيل مقاصد رمزك - سواء بالنسبة للآخرين <em>أو</em> لمستقبلك. </section>
## Instructions
<section id="instructions"> حاول إنشاء واحد من كل نوع من التعليقات. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: أنشئ تعليقًا بنمط <code>//</code> يحتوي على خمس رسائل على الأقل.
testString: 'assert(code.match(/(\/\/)...../g), "Create a <code>//</code> style comment that contains at least five letters.");'
- text: أنشئ تعليقًا بنمط <code>/* */</code> يحتوي على خمس رسائل على الأقل.
testString: 'assert(code.match(/(\/\*)([^\/]{5,})(?=\*\/)/gm), "Create a <code>/* */</code> style comment that contains at least five letters.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,64 @@
---
id: 56533eb9ac21ba0edf2244d0
title: Comparison with the Equality Operator
challengeType: 1
videoUrl: ''
localeTitle: مقارنة مع مشغل المساواة
---
## Description
<section id="description"> هناك العديد من <dfn>مشغلي المقارنة</dfn> في JavaScript. كل هذه العوامل إرجاع منطقية <code>true</code> أو <code>false</code> القيمة. المشغل الأساسي هو مشغل المساواة <code>==</code> . يقارن عامل المساواة بين قيمتين ويعرض <code>true</code> إذا كانت مكافئة أو <code>false</code> إذا لم تكن كذلك. لاحظ أن المساواة تختلف عن الواجب ( <code>=</code> ) ، الذي يعين القيمة على يمين المشغل إلى متغير في اليسار. <blockquote style=";text-align:right;direction:rtl"> الوظيفة equalestTest (myVal) { <br> if (myVal == 10) { <br> العودة &quot;يساوي&quot; ؛ <br> } <br> &quot;لا يساوي&quot;؛ <br> } </blockquote> إذا كانت <code>myVal</code> تساوي <code>10</code> ، <code>myVal</code> عامل التساوي <code>true</code> ، لذا سيتم تنفيذ الشفرة في الأقواس المتعرجة ، وستعرض الدالة <code>&quot;Equal&quot;</code> . خلاف ذلك ، ستقوم الدالة بإرجاع <code>&quot;Not Equal&quot;</code> . لكي تتمكن JavaScript من مقارنة نوعين مختلفين من <code>data types</code> (على سبيل المثال ، <code>numbers</code> <code>strings</code> ) ، يجب أن تقوم بتحويل نوع واحد إلى آخر. هذا هو المعروف باسم &quot;نوع الإكراه&quot;. وبمجرد الانتهاء من ذلك ، يمكن مقارنة الشروط كما يلي: <blockquote style=";text-align:right;direction:rtl"> 1 == 1 // true <br> 1 == 2 // false <br> 1 == &#39;1&#39; // true <br> &quot;3&quot; == 3 // true </blockquote></section>
## Instructions
<section id="instructions"> أضف <code>equality operator</code> إلى الخط المحدد بحيث تقوم الدالة بإرجاع &quot;Equal&quot; عندما يكون <code>val</code> مساويًا لـ <code>12</code> </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>testEqual(10)</code> يجب أن ترجع &quot;غير مساوي&quot;
testString: 'assert(testEqual(10) === "Not Equal", "<code>testEqual(10)</code> should return "Not Equal"");'
- text: <code>testEqual(12)</code> يجب أن ترجع &quot;Equal&quot;
testString: 'assert(testEqual(12) === "Equal", "<code>testEqual(12)</code> should return "Equal"");'
- text: <code>testEqual(&quot;12&quot;)</code> إرجاع &quot;Equal&quot;
testString: 'assert(testEqual("12") === "Equal", "<code>testEqual("12")</code> should return "Equal"");'
- text: يجب عليك استخدام عامل التشغيل <code>==</code>
testString: 'assert(code.match(/==/g) && !code.match(/===/g), "You should use the <code>==</code> operator");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Setup
function testEqual(val) {
if (val) { // Change this line
return "Equal";
}
return "Not Equal";
}
// Change this value to test
testEqual(10);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,76 @@
---
id: 56533eb9ac21ba0edf2244d4
title: Comparison with the Greater Than Operator
challengeType: 1
videoUrl: ''
localeTitle: مقارنة مع أكبر من المشغل
---
## Description
<section id="description"> أكبر من المشغل ( <code>&gt;</code> ) يقارن قيم رقمين. إذا كان الرقم إلى اليسار أكبر من الرقم إلى اليمين ، فسيعود إلى <code>true</code> . خلاف ذلك ، فإنها ترجع <code>false</code> . مثل المشغل المساواة ، أكبر من المشغل سوف يحول أنواع البيانات من القيم في حين مقارنة. <strong>أمثلة</strong> <blockquote style=";text-align:right;direction:rtl"> 5&gt; 3 // صحيح <br> 7&gt; &#39;3&#39; // true <br> 2&gt; 3 // false <br> &#39;1&#39;&gt; 9 // false </blockquote></section>
## Instructions
<section id="instructions"> إضافة <code>greater than</code> المشغل إلى الخطوط المشار إليها بحيث تكون عبارات العودة منطقية. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن <code>testGreaterThan(0)</code> &quot;10 أو أقل&quot;
testString: 'assert(testGreaterThan(0) === "10 or Under", "<code>testGreaterThan(0)</code> should return "10 or Under"");'
- text: <code>testGreaterThan(10)</code> إرجاع &quot;10 أو أقل&quot;
testString: 'assert(testGreaterThan(10) === "10 or Under", "<code>testGreaterThan(10)</code> should return "10 or Under"");'
- text: يجب أن ترجع <code>testGreaterThan(11)</code> &quot;أكثر من 10&quot;
testString: 'assert(testGreaterThan(11) === "Over 10", "<code>testGreaterThan(11)</code> should return "Over 10"");'
- text: <code>testGreaterThan(99)</code> إرجاع &quot;أكثر من 10&quot;
testString: 'assert(testGreaterThan(99) === "Over 10", "<code>testGreaterThan(99)</code> should return "Over 10"");'
- text: <code>testGreaterThan(100)</code> إرجاع &quot;أكثر من 10&quot;
testString: 'assert(testGreaterThan(100) === "Over 10", "<code>testGreaterThan(100)</code> should return "Over 10"");'
- text: <code>testGreaterThan(101)</code> إرجاع &quot;أكثر من 100&quot;
testString: 'assert(testGreaterThan(101) === "Over 100", "<code>testGreaterThan(101)</code> should return "Over 100"");'
- text: <code>testGreaterThan(150)</code> إرجاع &quot;أكثر من 100&quot;
testString: 'assert(testGreaterThan(150) === "Over 100", "<code>testGreaterThan(150)</code> should return "Over 100"");'
- text: يجب عليك استخدام <code>&gt;</code> مشغل على الأقل مرتين
testString: 'assert(code.match(/val\s*>\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>&gt;</code> operator at least twice");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function testGreaterThan(val) {
if (val) { // Change this line
return "Over 100";
}
if (val) { // Change this line
return "Over 10";
}
return "10 or Under";
}
// Change this value to test
testGreaterThan(10);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,76 @@
---
id: 56533eb9ac21ba0edf2244d5
title: Comparison with the Greater Than Or Equal To Operator
challengeType: 1
videoUrl: ''
localeTitle: مقارنة مع أكبر من أو يساوي المشغل
---
## Description
<section id="description"> يقارن العامل <code>greater than or equal to</code> ( <code>&gt;=</code> ) قيم رقمين. إذا كان الرقم إلى اليسار أكبر من أو يساوي الرقم إلى اليمين ، فإنه يُرجع <code>true</code> . خلاف ذلك ، فإنها ترجع <code>false</code> . مثل مشغل عامل المساواة ، فإن <code>greater than or equal to</code> المشغل سيقوم بتحويل أنواع البيانات أثناء المقارنة. <strong>أمثلة</strong> <blockquote style=";text-align:right;direction:rtl"> 6&gt; = 6 // true <br> 7&gt; = &#39;3&#39; // true <br> 2&gt; = 3 // false <br> &#39;7&#39;&gt; = 9 // false </blockquote></section>
## Instructions
<section id="instructions"> إضافة <code>greater than or equal to</code> المشغل إلى الخطوط المشار إليها بحيث تكون عبارات العودة منطقية. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن <code>testGreaterOrEqual(0)</code> &quot;أقل من 10&quot;
testString: 'assert(testGreaterOrEqual(0) === "Less than 10", "<code>testGreaterOrEqual(0)</code> should return "Less than 10"");'
- text: <code>testGreaterOrEqual(9)</code> إرجاع &quot;أقل من 10&quot;
testString: 'assert(testGreaterOrEqual(9) === "Less than 10", "<code>testGreaterOrEqual(9)</code> should return "Less than 10"");'
- text: يجب أن <code>testGreaterOrEqual(10)</code> &quot;10 أو أكثر&quot;
testString: 'assert(testGreaterOrEqual(10) === "10 or Over", "<code>testGreaterOrEqual(10)</code> should return "10 or Over"");'
- text: <code>testGreaterOrEqual(11)</code> إرجاع &quot;10 أو أكثر&quot;
testString: 'assert(testGreaterOrEqual(11) === "10 or Over", "<code>testGreaterOrEqual(11)</code> should return "10 or Over"");'
- text: <code>testGreaterOrEqual(19)</code> إرجاع &quot;10 أو أكثر&quot;
testString: 'assert(testGreaterOrEqual(19) === "10 or Over", "<code>testGreaterOrEqual(19)</code> should return "10 or Over"");'
- text: يجب أن <code>testGreaterOrEqual(100)</code> &quot;20 أو أكثر&quot;
testString: 'assert(testGreaterOrEqual(100) === "20 or Over", "<code>testGreaterOrEqual(100)</code> should return "20 or Over"");'
- text: <code>testGreaterOrEqual(21)</code> إرجاع &quot;20 أو أكثر&quot;
testString: 'assert(testGreaterOrEqual(21) === "20 or Over", "<code>testGreaterOrEqual(21)</code> should return "20 or Over"");'
- text: يجب عليك استخدام <code>&gt;=</code> عامل التشغيل على الأقل مرتين
testString: 'assert(code.match(/val\s*>=\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>&gt;=</code> operator at least twice");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function testGreaterOrEqual(val) {
if (val) { // Change this line
return "20 or Over";
}
if (val) { // Change this line
return "10 or Over";
}
return "Less than 10";
}
// Change this value to test
testGreaterOrEqual(10);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,68 @@
---
id: 56533eb9ac21ba0edf2244d2
title: Comparison with the Inequality Operator
challengeType: 1
videoUrl: ''
localeTitle: مقارنة مع مشغل عدم المساواة
---
## Description
<section id="description"> عامل عدم المساواة ( <code>!=</code> ) هو عكس مشغل المساواة. يعني &quot;غير متساوٍ&quot; ويعيد <code>false</code> حيث أن المساواة ستعود <code>true</code> <em>والعكس صحيح</em> . وعلى غرار مشغل المساواة ، يقوم مشغل عدم المساواة بتحويل أنواع البيانات من القيم عند المقارنة. <strong>أمثلة</strong> <blockquote style=";text-align:right;direction:rtl"> 1! = 2 / صحيح <br> 1! = &quot;1&quot; // false <br> 1! = &#39;1&#39; // false <br> 1! = true // false <br> 0! = false // false </blockquote></section>
## Instructions
<section id="instructions"> إضافة عامل عدم المساواة <code>!=</code> في جملة <code>if</code> بحيث تقوم الدالة بإرجاع &quot;غير مساوي&quot; عندما لا يكون <code>val</code> مساوياً لـ <code>99</code> </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>testNotEqual(99)</code> يجب أن ترجع &quot;Equal&quot;
testString: 'assert(testNotEqual(99) === "Equal", "<code>testNotEqual(99)</code> should return "Equal"");'
- text: <code>testNotEqual(&quot;99&quot;)</code> يجب أن يقوم بإرجاع &quot;Equal&quot;
testString: 'assert(testNotEqual("99") === "Equal", "<code>testNotEqual("99")</code> should return "Equal"");'
- text: يجب أن <code>testNotEqual(12)</code> &quot;غير مساوي&quot;
testString: 'assert(testNotEqual(12) === "Not Equal", "<code>testNotEqual(12)</code> should return "Not Equal"");'
- text: <code>testNotEqual(&quot;12&quot;)</code> &quot;غير مساوي&quot;
testString: 'assert(testNotEqual("12") === "Not Equal", "<code>testNotEqual("12")</code> should return "Not Equal"");'
- text: <code>testNotEqual(&quot;bob&quot;)</code> &quot;غير مساوي&quot;
testString: 'assert(testNotEqual("bob") === "Not Equal", "<code>testNotEqual("bob")</code> should return "Not Equal"");'
- text: يجب عليك استخدام <code>!=</code> عامل التشغيل
testString: 'assert(code.match(/(?!!==)!=/), "You should use the <code>!=</code> operator");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Setup
function testNotEqual(val) {
if (val) { // Change this line
return "Not Equal";
}
return "Equal";
}
// Change this value to test
testNotEqual(10);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,74 @@
---
id: 56533eb9ac21ba0edf2244d6
title: Comparison with the Less Than Operator
challengeType: 1
videoUrl: ''
localeTitle: مقارنة مع أقل من المشغل
---
## Description
<section id="description"> يقارن <dfn>أقل من</dfn> المشغل ( <code>&lt;</code> ) قيم رقمين. إذا كان الرقم إلى اليسار أقل من الرقم إلى اليمين ، فسيعود إلى الحالة <code>true</code> . خلاف ذلك ، فإنها ترجع <code>false</code> . مثل المشغل المساواة ، <dfn>أقل من</dfn> المشغل يحول أنواع البيانات أثناء مقارنة. <strong>أمثلة</strong> <blockquote style=";text-align:right;direction:rtl"> 2 &lt;5 / صحيح <br> &quot;3&quot; &lt;7 // صحيح <br> 5 &lt;5 // خاطئة <br> 3 &lt;2 // false <br> &quot;8&quot; &lt;4 // كاذبة </blockquote></section>
## Instructions
<section id="instructions"> إضافة <code>less than</code> المشغل إلى الخطوط المشار إليها بحيث تكون عبارات العودة منطقية. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن ترجع <code>testLessThan(0)</code> &quot;تحت 25&quot;
testString: 'assert(testLessThan(0) === "Under 25", "<code>testLessThan(0)</code> should return "Under 25"");'
- text: يجب أن ترجع <code>testLessThan(24)</code> &quot;تحت 25&quot;
testString: 'assert(testLessThan(24) === "Under 25", "<code>testLessThan(24)</code> should return "Under 25"");'
- text: يجب أن ترجع <code>testLessThan(25)</code> &quot;تحت 55&quot;
testString: 'assert(testLessThan(25) === "Under 55", "<code>testLessThan(25)</code> should return "Under 55"");'
- text: يجب أن ترجع <code>testLessThan(54)</code> &quot;تحت 55&quot;
testString: 'assert(testLessThan(54) === "Under 55", "<code>testLessThan(54)</code> should return "Under 55"");'
- text: <code>testLessThan(55)</code> إرجاع &quot;55 أو أكثر&quot;
testString: 'assert(testLessThan(55) === "55 or Over", "<code>testLessThan(55)</code> should return "55 or Over"");'
- text: يجب أن ترجع <code>testLessThan(99)</code> &quot;55 أو أكثر&quot;
testString: 'assert(testLessThan(99) === "55 or Over", "<code>testLessThan(99)</code> should return "55 or Over"");'
- text: يجب عليك استخدام <code>&lt;</code> المشغل مرتين على الأقل
testString: 'assert(code.match(/val\s*<\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>&lt;</code> operator at least twice");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function testLessThan(val) {
if (val) { // Change this line
return "Under 25";
}
if (val) { // Change this line
return "Under 55";
}
return "55 or Over";
}
// Change this value to test
testLessThan(10);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,76 @@
---
id: 56533eb9ac21ba0edf2244d7
title: Comparison with the Less Than Or Equal To Operator
challengeType: 1
videoUrl: ''
localeTitle: مقارنة مع أقل من أو يساوي المشغل
---
## Description
<section id="description"> يقارن <code>less than or equal to</code> المشغل ( <code>&lt;=</code> ) قيم رقمين. إذا كان الرقم إلى اليسار أقل من أو يساوي الرقم إلى اليمين ، فسيعود إلى <code>true</code> . إذا كان الرقم الموجود على اليسار أكبر من الرقم الموجود على اليمين ، فسيعرض <code>false</code> . مثل مشغل المساواة ، <code>less than or equal to</code> تحويل أنواع البيانات. <strong>أمثلة</strong> <blockquote style=";text-align:right;direction:rtl"> 4 &lt;= 5 // صحيح <br> &quot;7&quot; &lt;= 7 // صحيح <br> 5 &lt;= 5 // صحيح <br> 3 &lt;= 2 // خطأ <br> &quot;8&quot; &lt;= 4 // كاذبة </blockquote></section>
## Instructions
<section id="instructions"> إضافة <code>less than or equal to</code> المشغل إلى الخطوط المشار إليها بحيث تكون عبارات العودة منطقية. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن ترجع <code>testLessOrEqual(0)</code> &quot;Smaller Than أو Equal إلى 12&quot;
testString: 'assert(testLessOrEqual(0) === "Smaller Than or Equal to 12", "<code>testLessOrEqual(0)</code> should return "Smaller Than or Equal to 12"");'
- text: يجب أن ترجع <code>testLessOrEqual(11)</code> &quot;أصغر من أو يساوي إلى 12&quot;
testString: 'assert(testLessOrEqual(11) === "Smaller Than or Equal to 12", "<code>testLessOrEqual(11)</code> should return "Smaller Than or Equal to 12"");'
- text: يجب أن ترجع <code>testLessOrEqual(12)</code> &quot;Smaller Than أو Equal إلى 12&quot;
testString: 'assert(testLessOrEqual(12) === "Smaller Than or Equal to 12", "<code>testLessOrEqual(12)</code> should return "Smaller Than or Equal to 12"");'
- text: يجب أن ترجع <code>testLessOrEqual(23)</code> &quot;Smaller Than أو Equal إلى 24&quot;
testString: 'assert(testLessOrEqual(23) === "Smaller Than or Equal to 24", "<code>testLessOrEqual(23)</code> should return "Smaller Than or Equal to 24"");'
- text: يجب أن ترجع <code>testLessOrEqual(24)</code> &quot;Smaller Than أو Equal إلى 24&quot;
testString: 'assert(testLessOrEqual(24) === "Smaller Than or Equal to 24", "<code>testLessOrEqual(24)</code> should return "Smaller Than or Equal to 24"");'
- text: يجب أن ترجع <code>testLessOrEqual(25)</code> &quot;أكثر من 24&quot;
testString: 'assert(testLessOrEqual(25) === "More Than 24", "<code>testLessOrEqual(25)</code> should return "More Than 24"");'
- text: يجب أن ترجع <code>testLessOrEqual(55)</code> &quot;أكثر من 24&quot;
testString: 'assert(testLessOrEqual(55) === "More Than 24", "<code>testLessOrEqual(55)</code> should return "More Than 24"");'
- text: يجب عليك استخدام <code>&lt;=</code> عامل التشغيل على الأقل مرتين
testString: 'assert(code.match(/val\s*<=\s*("|")*\d+("|")*/g).length > 1, "You should use the <code>&lt;=</code> operator at least twice");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function testLessOrEqual(val) {
if (val) { // Change this line
return "Smaller Than or Equal to 12";
}
if (val) { // Change this line
return "Smaller Than or Equal to 24";
}
return "More Than 24";
}
// Change this value to test
testLessOrEqual(10);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,64 @@
---
id: 56533eb9ac21ba0edf2244d1
title: Comparison with the Strict Equality Operator
challengeType: 1
videoUrl: ''
localeTitle: مقارنة مع مشغل المساواة الصارمة
---
## Description
<section id="description"> المساواة <code>===</code> ( <code>===</code> ) هي نظير مشغل المساواة ( <code>==</code> ). ومع ذلك ، على عكس مشغل المساواة ، الذي يحاول تحويل كلتا القيمتين مقارنة بالنوع الشائع ، فإن مشغل المساواة الصارم لا يقوم بتحويل نوع. إذا كانت القيم التي يتم مقارنتها لها أنواع مختلفة ، فإنها تعتبر غير متساوية ، وسيعود المشغل الصارم للمساواة كاذبة. <strong>أمثلة</strong> <blockquote style=";text-align:right;direction:rtl"> 3 === 3 // true <br> 3 === &#39;3&#39; // false </blockquote> في المثال الثاني ، <code>3</code> هو نوع <code>Number</code> و <code>&#39;3&#39;</code> هو نوع <code>String</code> . </section>
## Instructions
<section id="instructions"> استخدم عامل التساوي الصارم في العبارة <code>if</code> بحيث تقوم الدالة بإرجاع &quot;Equal&quot; عندما تكون <code>val</code> تساوي تمامًا <code>7</code> </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن ترجع <code>testStrict(10)</code> &quot;غير مساوي&quot;
testString: 'assert(testStrict(10) === "Not Equal", "<code>testStrict(10)</code> should return "Not Equal"");'
- text: <code>testStrict(7)</code> إرجاع &quot;Equal&quot;
testString: 'assert(testStrict(7) === "Equal", "<code>testStrict(7)</code> should return "Equal"");'
- text: <code>testStrict(&quot;7&quot;)</code> إرجاع &quot;غير مساوي&quot;
testString: 'assert(testStrict("7") === "Not Equal", "<code>testStrict("7")</code> should return "Not Equal"");'
- text: يجب عليك استخدام عامل التشغيل <code>===</code>
testString: 'assert(code.match(/(val\s*===\s*\d+)|(\d+\s*===\s*val)/g).length > 0, "You should use the <code>===</code> operator");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Setup
function testStrict(val) {
if (val) { // Change this line
return "Equal";
}
return "Not Equal";
}
// Change this value to test
testStrict(10);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,71 @@
---
id: 56533eb9ac21ba0edf2244d3
title: Comparison with the Strict Inequality Operator
challengeType: 1
videoUrl: ''
localeTitle: مقارنة مع مشغل عدم المساواة الصارم
---
## Description
<section id="description"> إن عامل عدم المساواة الصارم ( <code>!==</code> ) هو المقابل المنطقي للمشغل الصارم للمساواة. ويعني &quot;عدم التساوي في الدقة&quot; ويعود <code>false</code> حيث تعود المساواة الصارمة إلى <code>true</code> <em>والعكس صحيح</em> . عدم المساواة الصارمة لن تقوم بتحويل أنواع البيانات. <strong>أمثلة</strong> <blockquote style=";text-align:right;direction:rtl"> 3! == 3 // false <br> 3! == &#39;3&#39; // true <br> 4! == 3 // صحيح </blockquote></section>
## Instructions
<section id="instructions"> إضافة <code>strict inequality operator</code> إلى العبارة <code>if</code> بحيث تقوم الدالة بإرجاع &quot;غير مساوي&quot; عندما لا يكون <code>val</code> مساوياً تمامًا لـ <code>17</code> </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>testStrictNotEqual(17)</code> إرجاع &quot;مساواة&quot;
testString: 'assert(testStrictNotEqual(17) === "Equal", "<code>testStrictNotEqual(17)</code> should return "Equal"");'
- text: <code>testStrictNotEqual(&quot;17&quot;)</code> &quot;غير مساوي&quot;
testString: 'assert(testStrictNotEqual("17") === "Not Equal", "<code>testStrictNotEqual("17")</code> should return "Not Equal"");'
- text: يجب أن <code>testStrictNotEqual(12)</code> &quot;غير مساوي&quot;
testString: 'assert(testStrictNotEqual(12) === "Not Equal", "<code>testStrictNotEqual(12)</code> should return "Not Equal"");'
- text: <code>testStrictNotEqual(&quot;bob&quot;)</code> &quot;غير مساوي&quot;
testString: 'assert(testStrictNotEqual("bob") === "Not Equal", "<code>testStrictNotEqual("bob")</code> should return "Not Equal"");'
- text: يجب عليك استخدام <code>!==</code> المشغل
testString: 'assert(code.match(/(val\s*!==\s*\d+)|(\d+\s*!==\s*val)/g).length > 0, "You should use the <code>!==</code> operator");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Setup
function testStrictNotEqual(val) {
// Only Change Code Below this Line
if (val) {
// Only Change Code Above this Line
return "Not Equal";
}
return "Equal";
}
// Change this value to test
testStrictNotEqual(10);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,81 @@
---
id: 56533eb9ac21ba0edf2244d8
title: Comparisons with the Logical And Operator
challengeType: 1
videoUrl: ''
localeTitle: مقارنات مع المنطقية والمشغل
---
## Description
<section id="description"> في بعض الأحيان ستحتاج إلى اختبار أكثر من شيء واحد في كل مرة. إرجاع <dfn>المنطقية</dfn> والمشغل ( <code>&amp;&amp;</code> ) <code>true</code> إذا وفقط إذا كانت <dfn>المعاملات</dfn> إلى اليسار واليمين صحيحاً. يمكن تحقيق نفس التأثير بتضمين جملة if داخل أخرى إذا: <blockquote style=";text-align:right;direction:rtl"> if (num&gt; 5) { <br> إذا (عدد &lt;10) { <br> العودة &quot;نعم&quot; ؛ <br> } <br> } <br> العودة &quot;لا&quot; ؛ </blockquote> سيعود فقط &quot;نعم&quot; إذا <code>num</code> أكبر من <code>5</code> وأقل من <code>10</code> . نفس المنطق يمكن كتابته على النحو التالي: <blockquote style=";text-align:right;direction:rtl"> if (num&gt; 5 &amp; num &lt;10) { <br> العودة &quot;نعم&quot; ؛ <br> } <br> العودة &quot;لا&quot; ؛ </blockquote></section>
## Instructions
<section id="instructions"> قم بدمج العبارة &quot;if&quot; في عبارة واحدة والتي ستُرجع <code>&quot;Yes&quot;</code> إذا كان <code>val</code> أقل من أو يساوي <code>50</code> وأكبر من أو يساوي <code>25</code> . خلاف ذلك ، سيعود <code>&quot;No&quot;</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب عليك استخدام مشغل <code>&amp;&amp;</code> مرة واحدة
testString: 'assert(code.match(/&&/g).length === 1, "You should use the <code>&&</code> operator once");'
- text: يجب أن يكون لديك واحد فقط <code>if</code> البيان
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement");'
- text: يجب أن ترجع <code>testLogicalAnd(0)</code> &quot;لا&quot;
testString: 'assert(testLogicalAnd(0) === "No", "<code>testLogicalAnd(0)</code> should return "No"");'
- text: <code>testLogicalAnd(24)</code> يجب أن ترجع &quot;لا&quot;
testString: 'assert(testLogicalAnd(24) === "No", "<code>testLogicalAnd(24)</code> should return "No"");'
- text: <code>testLogicalAnd(25)</code> يجب أن ترجع &quot;Yes&quot;
testString: 'assert(testLogicalAnd(25) === "Yes", "<code>testLogicalAnd(25)</code> should return "Yes"");'
- text: يجب أن ترجع <code>testLogicalAnd(30)</code> &quot;نعم&quot;
testString: 'assert(testLogicalAnd(30) === "Yes", "<code>testLogicalAnd(30)</code> should return "Yes"");'
- text: يجب أن ترجع <code>testLogicalAnd(50)</code> &quot;نعم&quot;
testString: 'assert(testLogicalAnd(50) === "Yes", "<code>testLogicalAnd(50)</code> should return "Yes"");'
- text: <code>testLogicalAnd(51)</code> يجب أن ترجع &quot;لا&quot;
testString: 'assert(testLogicalAnd(51) === "No", "<code>testLogicalAnd(51)</code> should return "No"");'
- text: يجب أن <code>testLogicalAnd(75)</code> &quot;لا&quot;
testString: 'assert(testLogicalAnd(75) === "No", "<code>testLogicalAnd(75)</code> should return "No"");'
- text: <code>testLogicalAnd(80)</code> يجب أن ترجع &quot;لا&quot;
testString: 'assert(testLogicalAnd(80) === "No", "<code>testLogicalAnd(80)</code> should return "No"");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function testLogicalAnd(val) {
// Only change code below this line
if (val) {
if (val) {
return "Yes";
}
}
// Only change code above this line
return "No";
}
// Change this value to test
testLogicalAnd(10);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,83 @@
---
id: 56533eb9ac21ba0edf2244d9
title: Comparisons with the Logical Or Operator
challengeType: 1
videoUrl: ''
localeTitle: مقارنات مع المنطقي أو المشغل
---
## Description
<section id="description"> إرجاع <dfn>المنطقية أو</dfn> عامل التشغيل ( <code>||</code> ) <code>true</code> إذا كان أي من <dfn>المعاملات</dfn> <code>true</code> . خلاف ذلك ، فإنها ترجع <code>false</code> . <dfn>المنطقي أو</dfn> المشغل يتكون من اثنين من رموز الأنبوب ( <code>|</code> ). يمكن العثور على ذلك عادةً بين مفتاحي Backspace و Enter. يجب أن يبدو النمط أدناه مألوفًا من نقاط الطريق السابقة: <blockquote style=";text-align:right;direction:rtl"> if (num&gt; 10) { <br> العودة &quot;لا&quot; ؛ <br> } <br> إذا (عدد &lt;5) { <br> العودة &quot;لا&quot; ؛ <br> } <br> العودة &quot;نعم&quot; ؛ </blockquote> سيعود &quot;نعم&quot; إلا إذا <code>num</code> ما بين <code>5</code> و <code>10</code> (5 و 10 مدرجة). نفس المنطق يمكن كتابته على النحو التالي: <blockquote style=";text-align:right;direction:rtl"> if (num&gt; 10 || num &lt;5) { <br> العودة &quot;لا&quot; ؛ <br> } <br> العودة &quot;نعم&quot; ؛ </blockquote></section>
## Instructions
<section id="instructions"> اجمع بين العبارة &quot; <code>if</code> في عبارة واحدة والتي تُرجع <code>&quot;Outside&quot;</code> إذا لم يكن <code>val</code> ما بين <code>10</code> و <code>20</code> ضمناً. خلاف ذلك ، والعودة <code>&quot;Inside&quot;</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب عليك استخدام <code>||</code> عامل مرة واحدة
testString: 'assert(code.match(/\|\|/g).length === 1, "You should use the <code>||</code> operator once");'
- text: يجب أن يكون لديك واحد فقط <code>if</code> البيان
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement");'
- text: يجب أن ترجع <code>testLogicalOr(0)</code> &quot;خارج&quot;
testString: 'assert(testLogicalOr(0) === "Outside", "<code>testLogicalOr(0)</code> should return "Outside"");'
- text: يجب أن ترجع <code>testLogicalOr(9)</code> &quot;خارج&quot;
testString: 'assert(testLogicalOr(9) === "Outside", "<code>testLogicalOr(9)</code> should return "Outside"");'
- text: <code>testLogicalOr(10)</code> إرجاع &quot;Inside&quot;
testString: 'assert(testLogicalOr(10) === "Inside", "<code>testLogicalOr(10)</code> should return "Inside"");'
- text: <code>testLogicalOr(15)</code> إرجاع &quot;Inside&quot;
testString: 'assert(testLogicalOr(15) === "Inside", "<code>testLogicalOr(15)</code> should return "Inside"");'
- text: <code>testLogicalOr(19)</code> إرجاع &quot;Inside&quot;
testString: 'assert(testLogicalOr(19) === "Inside", "<code>testLogicalOr(19)</code> should return "Inside"");'
- text: <code>testLogicalOr(20)</code> إرجاع &quot;Inside&quot;
testString: 'assert(testLogicalOr(20) === "Inside", "<code>testLogicalOr(20)</code> should return "Inside"");'
- text: يجب أن ترجع <code>testLogicalOr(21)</code> &quot;خارج&quot;
testString: 'assert(testLogicalOr(21) === "Outside", "<code>testLogicalOr(21)</code> should return "Outside"");'
- text: يجب أن ترجع <code>testLogicalOr(25)</code> &quot;خارج&quot;
testString: 'assert(testLogicalOr(25) === "Outside", "<code>testLogicalOr(25)</code> should return "Outside"");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function testLogicalOr(val) {
// Only change code below this line
if (val) {
return "Outside";
}
if (val) {
return "Outside";
}
// Only change code above this line
return "Inside";
}
// Change this value to test
testLogicalOr(15);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,73 @@
---
id: 56533eb9ac21ba0edf2244af
title: Compound Assignment With Augmented Addition
challengeType: 1
videoUrl: ''
localeTitle: مهمة مركبة مع إضافة مضافة
---
## Description
<section id="description"> في البرمجة ، من الشائع استخدام التعيينات لتعديل محتويات المتغير. تذكر أن كل شيء على يمين علامة المساواة يتم تقييمه أولاً ، حتى يمكننا قول: <code>myVar = myVar + 5;</code> لإضافة <code>5</code> إلى <code>myVar</code> . بما أن هذا هو النمط الشائع ، فهناك مشغلين يقومون بعملية رياضية وتعيين في خطوة واحدة. أحد هذه المشغلات هو عامل <code>+=</code> . <blockquote style=";text-align:right;direction:rtl"> var myVar = 1 ، <br> myVar + = 5؛ <br> console.log (myVar)؛ // إرجاع 6 </blockquote></section>
## Instructions
<section id="instructions"> قم بتحويل التعيينات لـ <code>a</code> و <code>b</code> و <code>c</code> لاستخدام <code>+=</code> عامل التشغيل. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>a</code> يجب أن يساوي <code>15</code>
testString: 'assert(a === 15, "<code>a</code> should equal <code>15</code>");'
- text: <code>b</code> يجب أن تساوي <code>26</code>
testString: 'assert(b === 26, "<code>b</code> should equal <code>26</code>");'
- text: <code>c</code> يجب أن تساوي <code>19</code>
testString: 'assert(c === 19, "<code>c</code> should equal <code>19</code>");'
- text: يجب عليك استخدام <code>+=</code> عامل لكل متغير
testString: 'assert(code.match(/\+=/g).length === 3, "You should use the <code>+=</code> operator for each variable");'
- text: لا تعدّل الشفرة فوق الخط
testString: 'assert(/var a = 3;/.test(code) && /var b = 17;/.test(code) && /var c = 12;/.test(code), "Do not modify the code above the line");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var a = 3;
var b = 17;
var c = 12;
// Only modify code below this line
a = a + 12;
b = 9 + b;
c = c + 7;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,73 @@
---
id: 56533eb9ac21ba0edf2244b2
title: Compound Assignment With Augmented Division
challengeType: 1
videoUrl: ''
localeTitle: تكليف مركب مع قسم معزز
---
## Description
<section id="description"> يقوم عامل التشغيل <code>/=</code> بتقسيم متغير برقم آخر. <code>myVar = myVar / 5;</code> سوف يقسم <code>myVar</code> بنسبة <code>5</code> . يمكن إعادة كتابة هذا كـ: <code>myVar /= 5;</code> </section>
## Instructions
<section id="instructions"> قم بتحويل التعيينات لـ <code>a</code> و <code>b</code> و <code>c</code> لاستخدام <code>/=</code> operator. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>a</code> يجب أن يساوي <code>4</code>
testString: 'assert(a === 4, "<code>a</code> should equal <code>4</code>");'
- text: <code>b</code> يجب أن تساوي <code>27</code>
testString: 'assert(b === 27, "<code>b</code> should equal <code>27</code>");'
- text: <code>c</code> يجب أن يساوي <code>3</code>
testString: 'assert(c === 3, "<code>c</code> should equal <code>3</code>");'
- text: يجب عليك استخدام عامل التشغيل <code>/=</code> لكل متغير
testString: 'assert(code.match(/\/=/g).length === 3, "You should use the <code>/=</code> operator for each variable");'
- text: لا تعدّل الشفرة فوق الخط
testString: 'assert(/var a = 48;/.test(code) && /var b = 108;/.test(code) && /var c = 33;/.test(code), "Do not modify the code above the line");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var a = 48;
var b = 108;
var c = 33;
// Only modify code below this line
a = a / 12;
b = b / 4;
c = c / 11;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,73 @@
---
id: 56533eb9ac21ba0edf2244b1
title: Compound Assignment With Augmented Multiplication
challengeType: 1
videoUrl: ''
localeTitle: مهمة مركبة مع تكاثر مضاعف
---
## Description
<section id="description"> يقوم عامل التشغيل <code>*=</code> بضرب متغير برقم. <code>myVar = myVar * 5;</code> سوف تضاعف <code>myVar</code> بنسبة <code>5</code> . يمكن إعادة كتابة هذا كـ: <code>myVar *= 5;</code> </section>
## Instructions
<section id="instructions"> قم بتحويل التعيينات لـ <code>a</code> و <code>b</code> و <code>c</code> لاستخدام <code>*=</code> operator. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>a</code> يجب أن يساوي <code>25</code>
testString: 'assert(a === 25, "<code>a</code> should equal <code>25</code>");'
- text: <code>b</code> يجب أن تساوي <code>36</code>
testString: 'assert(b === 36, "<code>b</code> should equal <code>36</code>");'
- text: <code>c</code> يجب أن تساوي <code>46</code>
testString: 'assert(c === 46, "<code>c</code> should equal <code>46</code>");'
- text: يجب عليك استخدام عامل التشغيل <code>*=</code> لكل متغير
testString: 'assert(code.match(/\*=/g).length === 3, "You should use the <code>*=</code> operator for each variable");'
- text: لا تعدّل الشفرة فوق الخط
testString: 'assert(/var a = 5;/.test(code) && /var b = 12;/.test(code) && /var c = 4\.6;/.test(code), "Do not modify the code above the line");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var a = 5;
var b = 12;
var c = 4.6;
// Only modify code below this line
a = a * 5;
b = 3 * b;
c = c * 10;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,73 @@
---
id: 56533eb9ac21ba0edf2244b0
title: Compound Assignment With Augmented Subtraction
challengeType: 1
videoUrl: ''
localeTitle: مهمة مركبة مع الطرح المعزز
---
## Description
<section id="description"> مثل <code>+=</code> عامل التشغيل ، <code>-=</code> طرح عدد من متغير. <code>myVar = myVar - 5;</code> سوف طرح <code>5</code> من <code>myVar</code> . يمكن إعادة كتابة هذا كـ: <code>myVar -= 5;</code> </section>
## Instructions
<section id="instructions"> قم بتحويل التعيينات لـ <code>a</code> و <code>b</code> و <code>c</code> لاستخدام عامل التشغيل <code>-=</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>a</code> يجب أن يساوي <code>5</code>
testString: 'assert(a === 5, "<code>a</code> should equal <code>5</code>");'
- text: <code>b</code> ينبغي أن تساوي <code>-6</code>
testString: 'assert(b === -6, "<code>b</code> should equal <code>-6</code>");'
- text: <code>c</code> يجب أن تساوي <code>2</code>
testString: 'assert(c === 2, "<code>c</code> should equal <code>2</code>");'
- text: يجب عليك استخدام <code>-=</code> عامل لكل متغير
testString: 'assert(code.match(/-=/g).length === 3, "You should use the <code>-=</code> operator for each variable");'
- text: لا تعدّل الشفرة فوق الخط
testString: 'assert(/var a = 11;/.test(code) && /var b = 9;/.test(code) && /var c = 3;/.test(code), "Do not modify the code above the line");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var a = 11;
var b = 9;
var c = 3;
// Only modify code below this line
a = a - 6;
b = b - 15;
c = c - 1;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,68 @@
---
id: 56533eb9ac21ba0edf2244b7
title: Concatenating Strings with Plus Operator
challengeType: 1
videoUrl: ''
localeTitle: سلاسل متسلسلة مع Plus Operator
---
## Description
<section id="description"> في JavaScript ، عندما يتم استخدام عامل التشغيل <code>+</code> مع قيمة <code>String</code> ، يطلق عليه عامل التشغيل <dfn>السلسة</dfn> . يمكنك إنشاء سلسلة جديدة خارج السلاسل الأخرى عن طريق <dfn>وصلها</dfn> معًا. <strong>مثال</strong> <blockquote style=";text-align:right;direction:rtl"> &quot;اسمي ألان ،&quot; + &quot;أنا سلسلته&quot;. </blockquote> <strong>ملحوظة</strong> <br> احترس من المساحات. لا يضيف Concatenation فراغات بين السلاسل المتسلسلة ، لذا ستحتاج إلى إضافتها بنفسك. </section>
## Instructions
<section id="instructions"> بناء <code>myStr</code> من السلاسل <code>&quot;This is the start. &quot;</code> و <code>&quot;This is the end.&quot;</code> باستخدام عامل <code>+</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن يكون لـ <code>myStr</code> قيمة <code>This is the start. This is the end.</code>
testString: 'assert(myStr === "This is the start. This is the end.", "<code>myStr</code> should have a value of <code>This is the start. This is the end.</code>");'
- text: استخدم عامل التشغيل <code>+</code> لبناء <code>myStr</code>
testString: 'assert(code.match(/([""]).*([""])\s*\+\s*([""]).*([""])/g).length > 1, "Use the <code>+</code> operator to build <code>myStr</code>");'
- text: يجب إنشاء <code>myStr</code> باستخدام الكلمة الرئيسية <code>var</code> .
testString: 'assert(/var\s+myStr/.test(code), "<code>myStr</code> should be created using the <code>var</code> keyword.");'
- text: تأكد من تعيين النتيجة لمتغير <code>myStr</code> .
testString: 'assert(/myStr\s*=/.test(code), "Make sure to assign the result to the <code>myStr</code> variable.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourStr = "I come first. " + "I come second.";
// Only change code below this line
var myStr;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,65 @@
---
id: 56533eb9ac21ba0edf2244b8
title: Concatenating Strings with the Plus Equals Operator
challengeType: 1
videoUrl: ''
localeTitle: سلاسل متسلسلة مع Plus Equals Operator
---
## Description
<section id="description"> يمكننا أيضًا استخدام <code>+=</code> operator <dfn>لسَلسَلة</dfn> سلسلة في نهاية متغير سلسلة موجود. يمكن أن يكون هذا مفيدًا جدًا لكسر سلسلة طويلة عبر عدة أسطر. <strong>ملحوظة</strong> <br> احترس من المساحات. لا يضيف Concatenation فراغات بين السلاسل المتسلسلة ، لذا ستحتاج إلى إضافتها بنفسك. </section>
## Instructions
<section id="instructions"> إنشاء <code>myStr</code> عبر عدة سطور عن طريق وصل هاتين السلسلتين: <code>&quot;This is the first sentence. &quot;</code> و <code>&quot;This is the second sentence.&quot;</code> باستخدام <code>+=</code> عامل التشغيل. استخدم <code>+=</code> عامل مشابه لكيفية ظهوره في المحرر. ابدأ بتخصيص السلسلة الأولى إلى <code>myStr</code> ، ثم أضفها في السلسلة الثانية. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن يكون لـ <code>myStr</code> قيمة <code>This is the first sentence. This is the second sentence.</code>
testString: 'assert(myStr === "This is the first sentence. This is the second sentence.", "<code>myStr</code> should have a value of <code>This is the first sentence. This is the second sentence.</code>");'
- text: استخدم <code>+=</code> عامل لبناء <code>myStr</code>
testString: 'assert(code.match(/\w\s*\+=\s*[""]/g).length > 1 && code.match(/\w\s*\=\s*[""]/g).length > 1, "Use the <code>+=</code> operator to build <code>myStr</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourStr = "I come first. ";
ourStr += "I come second.";
// Only change code below this line
var myStr;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,65 @@
---
id: 56533eb9ac21ba0edf2244b9
title: Constructing Strings with Variables
challengeType: 1
videoUrl: ''
localeTitle: بناء سلاسل مع المتغيرات
---
## Description
<section id="description"> في بعض الأحيان سوف تحتاج إلى بناء سلسلة ، نمط <a href="https://en.wikipedia.org/wiki/Mad_Libs" target="_blank">Mad Libs</a> . باستخدام عامل التشغيل السلسة ( <code>+</code> ) ، يمكنك إدراج متغير واحد أو أكثر في سلسلة تقوم ببنائها. </section>
## Instructions
<section id="instructions"> تعيين <code>myName</code> إلى سلسلة يساوي اسمك وبناء <code>myStr</code> مع <code>myName</code> بين الجمل <code>&quot;My name is &quot;</code> و <code>&quot; and I am well!&quot;</code> </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب تعيين <code>myName</code> إلى سلسلة لا تقل عن 3 أحرف
testString: 'assert(typeof myName !== "undefined" && myName.length > 2, "<code>myName</code> should be set to a string at least 3 characters long");'
- text: استخدام اثنين <code>+</code> المشغلين لبناء <code>myStr</code> مع <code>myName</code> داخله
testString: 'assert(code.match(/[""]\s*\+\s*myName\s*\+\s*[""]/g).length > 0, "Use two <code>+</code> operators to build <code>myStr</code> with <code>myName</code> inside it");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourName = "freeCodeCamp";
var ourStr = "Hello, our name is " + ourName + ", how are you?";
// Only change code below this line
var myName;
var myStr;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,71 @@
---
id: 56105e7b514f539506016a5e
title: Count Backwards With a For Loop
challengeType: 1
videoUrl: ''
localeTitle: عد إلى الخلف مع ل حلقة
---
## Description
<section id="description"> يمكن أيضًا حساب العروة للخلف ، طالما أننا نستطيع تحديد الشروط الصحيحة. من أجل احتساب العكسيتين بعلامة twos ، سنحتاج إلى تغيير <code>initialization</code> <code>condition</code> <code>final-expression</code> . سنبدأ عند <code>i = 10</code> والحلقة بينما <code>i &gt; 0</code> . سنقوم decrement <code>i</code> كل حلقة 2 مع <code>i -= 2</code> . <blockquote style=";text-align:right;direction:rtl"> var ourArray = []؛ <br> for (var i = 10؛ i&gt; 0؛ i- = 2) { <br> ourArray.push (ط)؛ <br> } </blockquote> <code>ourArray</code> الآن <code>[10,8,6,4,2]</code> . دعونا نغير <code>initialization</code> <code>final-expression</code> حتى نتمكن من العد إلى الوراء من خلال الاثنتين بالأرقام الفردية. </section>
## Instructions
<section id="instructions"> ادفع الأرقام الفردية من 9 إلى 1 إلى <code>myArray</code> باستخدام حلقة <code>for</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن تكون باستخدام <code>for</code> حلقة لهذا الغرض.
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
- text: يجب أن تستخدم <code>push</code> طريقة الصفيف.
testString: 'assert(code.match(/myArray.push/), "You should be using the array method <code>push</code>.");'
- text: '<code>myArray</code> ينبغي أن تساوي <code>[9,7,5,3,1]</code> .'
testString: 'assert.deepEqual(myArray, [9,7,5,3,1], "<code>myArray</code> should equal <code>[9,7,5,3,1]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourArray = [];
for (var i = 10; i > 0; i -= 2) {
ourArray.push(i);
}
// Setup
var myArray = [];
// Only change code below this line.
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,74 @@
---
id: 565bbe00e9cc8ac0725390f4
title: Counting Cards
challengeType: 1
videoUrl: ''
localeTitle: عد بطاقات
---
## Description
<section id="description"> في لعبة الكازينو Blackjack ، يمكن للاعب الحصول على ميزة على المنزل من خلال تتبع العدد النسبي للبطاقات العالية والمنخفضة المتبقية في سطح السفينة. وهذا ما يسمى <a href="https://en.wikipedia.org/wiki/Card_counting" target="_blank">حساب البطاقة</a> . وجود المزيد من البطاقات العالية المتبقية في سطح السفينة تفضل اللاعب. يتم تعيين قيمة لكل بطاقة وفقًا للجدول أدناه. عندما يكون العد موجبًا ، يجب أن يراهن اللاعب عالياً. عندما يكون العدد صفرًا أو سلبيًا ، يجب على اللاعب الرهان منخفضًا. <table class="table table-striped" style=";text-align:right;direction:rtl"><thead><tr><th> عد التغيير </th><th> بطاقات </th></tr></thead><tbody><tr><td> +1 </td><td> 2 و 3 و 4 و 5 و 6 </td></tr><tr><td> 0 </td><td> 7 و 8 و 9 </td></tr><tr><td> -1 </td><td> 10 ، &#39;J&#39; ، &#39;Q&#39; ، &#39;K&#39; ، &#39;A&#39; </td></tr></tbody></table> ستكتب وظيفة حساب البطاقة. سيحصل على معلمة <code>card</code> ، والتي يمكن أن تكون رقمًا أو سلسلة ، وزيادة أو إنقاص متغير <code>count</code> العالمي وفقًا لقيمة البطاقة (انظر الجدول). ستقوم الدالة بعد ذلك بإرجاع سلسلة مع العدد الحالي وسلسلة <code>Bet</code> إذا كان العدد موجبًا ، أو <code>Hold</code> إذا كان العدد صفراً أو سالباً. يجب فصل العدد الحالي وقرار اللاعب ( <code>Bet</code> أو <code>Hold</code> ) بمسافة واحدة. <strong>ناتج المثال</strong> <br> <code>-3 Hold</code> <br> <code>5 Bet</code> <strong>تلميح</strong> <code>5 Bet</code> <br> لا تقم بإعادة تعيين <code>count</code> إلى 0 عندما تكون القيمة 7 أو 8 أو 9. <br> لا ترجع مصفوفة. <br> لا تقم بتضمين علامات الاقتباس (مفردة أو مزدوجة) في الإخراج. </section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن تعود تسلسلات البطاقات 2 و 3 و 4 و 5 و 6 إلى <code>5 Bet</code>
testString: 'assert((function(){ count = 0; cc(2);cc(3);cc(4);cc(5);var out = cc(6); if(out === "5 Bet") {return true;} return false; })(), "Cards Sequence 2, 3, 4, 5, 6 should return <code>5 Bet</code>");'
- text: يجب أن تعود تسلسلات البطاقات 7 و 8 و 9 <code>0 Hold</code>
testString: 'assert((function(){ count = 0; cc(7);cc(8);var out = cc(9); if(out === "0 Hold") {return true;} return false; })(), "Cards Sequence 7, 8, 9 should return <code>0 Hold</code>");'
- text: يجب أن تعود تسلسلات البطاقات 10 و J و Q و K و A إلى <code>-5 Hold</code>
testString: 'assert((function(){ count = 0; cc(10);cc("J");cc("Q");cc("K");var out = cc("A"); if(out === "-5 Hold") {return true;} return false; })(), "Cards Sequence 10, J, Q, K, A should return <code>-5 Hold</code>");'
- text: يجب أن تعود تسلسلات البطاقات 3 و 7 و Q و 8 و A إلى <code>-1 Hold</code>
testString: 'assert((function(){ count = 0; cc(3);cc(7);cc("Q");cc(8);var out = cc("A"); if(out === "-1 Hold") {return true;} return false; })(), "Cards Sequence 3, 7, Q, 8, A should return <code>-1 Hold</code>");'
- text: يجب أن تعيد بطاقات التسلسل 2 ، J ، 9 ، 2 ، 7 <code>1 Bet</code>
testString: 'assert((function(){ count = 0; cc(2);cc("J");cc(9);cc(2);var out = cc(7); if(out === "1 Bet") {return true;} return false; })(), "Cards Sequence 2, J, 9, 2, 7 should return <code>1 Bet</code>");'
- text: يجب أن تعيد بطاقات التسلسل 2 و 2 و 10 <code>1 Bet</code>
testString: 'assert((function(){ count = 0; cc(2);cc(2);var out = cc(10); if(out === "1 Bet") {return true;} return false; })(), "Cards Sequence 2, 2, 10 should return <code>1 Bet</code>");'
- text: يجب أن تعود تسلسلات البطاقات 3 ، 2 ، A ، 10 ، K <code>-1 Hold</code>
testString: 'assert((function(){ count = 0; cc(3);cc(2);cc("A");cc(10);var out = cc("K"); if(out === "-1 Hold") {return true;} return false; })(), "Cards Sequence 3, 2, A, 10, K should return <code>-1 Hold</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var count = 0;
function cc(card) {
// Only change code below this line
return "Change Me";
// Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,61 @@
---
id: cf1391c1c11feddfaeb4bdef
title: Create Decimal Numbers with JavaScript
challengeType: 1
videoUrl: ''
localeTitle: قم بإنشاء أرقام عشرية باستخدام جافا سكريبت
---
## Description
<section id="description"> يمكننا تخزين الأرقام العشرية في المتغيرات أيضًا. ويشار إلى الأرقام العشرية في بعض الأحيان باسم أرقام <dfn>النقطة العائمة</dfn> أو <dfn>العوامات</dfn> . <strong>ملحوظة</strong> <br> لا يمكن تمثيل جميع الأرقام الحقيقية بدقة في <dfn>نقطة عائمة</dfn> . هذا يمكن أن يؤدي إلى أخطاء التقريب. <a href="https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems" target="_blank">التفاصيل هنا</a> . </section>
## Instructions
<section id="instructions"> إنشاء متغير <code>myDecimal</code> وإعطائه قيمة عشرية مع جزء كسري (على سبيل المثال <code>5.7</code> ). </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن يكون <code>myDecimal</code> رقمًا.
testString: 'assert(typeof myDecimal === "number", "<code>myDecimal</code> should be a number.");'
- text: <code>myDecimal</code> يجب أن يكون لديك <code>myDecimal</code> العشرية
testString: 'assert(myDecimal % 1 != 0, "<code>myDecimal</code> should have a decimal point"); '
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var ourDecimal = 5.7;
// Only change code below this line
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,60 @@
---
id: bd7123c9c443eddfaeb5bdef
title: Declare JavaScript Variables
challengeType: 1
videoUrl: ''
localeTitle: تحديد متغيرات جافا سكريبت
---
## Description
<section id="description"> في علم الكمبيوتر ، <dfn>البيانات</dfn> هي أي شيء مفيد للكمبيوتر. يوفر JavaScript سبعة <dfn>أنواع بيانات</dfn> مختلفة <code>undefined</code> ، <code>null</code> ، <code>boolean</code> ، <code>string</code> ، <code>symbol</code> ، <code>number</code> ، <code>object</code> . على سبيل المثال ، تميز أجهزة الكمبيوتر بين الأرقام ، مثل الرقم <code>12</code> ، <code>strings</code> ، مثل <code>&quot;12&quot;</code> أو <code>&quot;dog&quot;</code> أو <code>&quot;123 cats&quot;</code> ، وهي مجموعات من الأحرف. يمكن لأجهزة الكمبيوتر إجراء العمليات الحسابية على عدد ، ولكن ليس على سلسلة. تسمح <dfn>المتغيرات</dfn> لأجهزة الكمبيوتر بتخزين البيانات ومعالجتها بطريقة ديناميكية. يفعلون ذلك باستخدام &quot;تسمية&quot; للإشارة إلى البيانات بدلاً من استخدام البيانات نفسها. يمكن تخزين أي من أنواع البيانات السبعة في متغير. تشبه <code>Variables</code> x و y التي تستخدمها في الرياضيات ، مما يعني أنها اسم بسيط لتمثيل البيانات التي نريد الرجوع إليها. تختلف <code>variables</code> الكمبيوتر عن <code>variables</code> الرياضية في أنها يمكن أن تخزن قيمًا مختلفة في أوقات مختلفة. نقول جافا سكريبت لإنشاء أو <dfn>تعريف</dfn> متغير عن طريق وضع الكلمة <code>var</code> أمامه، كما يلي: <blockquote style=";text-align:right;direction:rtl"> var ourName؛ </blockquote> يخلق <code>variable</code> يسمى <code>ourName</code> . في جافا سكريبت ، ننتهي من العبارات بفواصل منقوطة. يمكن أن تتكون أسماء <code>Variable</code> من أرقام وأحرف و <code>$</code> أو <code>_</code> ، لكن قد لا تحتوي على مسافات أو تبدأ برقم. </section>
## Instructions
<section id="instructions"> استخدم الكلمة الأساسية <code>var</code> لإنشاء متغير يسمى <code>myName</code> . <strong>ملحوظة</strong> <br> انظر إلى مثال <code>ourName</code> إذا واجهتك <code>ourName</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن تعلن <code>myName</code> مع الكلمة الرئيسية <code>var</code> ، وتنتهي بفاصلة منقوطة
testString: 'assert(/var\s+myName\s*;/.test(code), "You should declare <code>myName</code> with the <code>var</code> keyword, ending with a semicolon");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourName;
// Declare myName below this line
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,63 @@
---
id: bd7123c9c444eddfaeb5bdef
title: Declare String Variables
challengeType: 1
videoUrl: ''
localeTitle: تعبير سلسلة المتغيرات
---
## Description
<section id="description"> سبق لنا استخدام الرمز <code>var myName = &quot;your name&quot;;</code> يسمى <code>&quot;your name&quot;</code> <dfn>سلسلة</dfn> <dfn>حرفية</dfn> . وهي سلسلة لأنها عبارة عن سلسلة من صفر أو أكثر من الأحرف محاطة بعلامات اقتباس مفردة أو مزدوجة. </section>
## Instructions
<section id="instructions"> إنشاء اثنين الجديدة <code>string</code> المتغيرات: <code>myFirstName</code> و <code>myLastName</code> وتعيينها القيم من الاسم الأول والأخير، على التوالي. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن يكون <code>myFirstName</code> عبارة عن سلسلة بها حرف واحد على الأقل.
testString: 'assert((function(){if(typeof myFirstName !== "undefined" && typeof myFirstName === "string" && myFirstName.length > 0){return true;}else{return false;}})(), "<code>myFirstName</code> should be a string with at least one character in it.");'
- text: يجب أن يكون <code>myLastName</code> عبارة عن سلسلة بها حرف واحد على الأقل.
testString: 'assert((function(){if(typeof myLastName !== "undefined" && typeof myLastName === "string" && myLastName.length > 0){return true;}else{return false;}})(), "<code>myLastName</code> should be a string with at least one character in it.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var firstName = "Alan";
var lastName = "Turing";
// Only change code below this line
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,66 @@
---
id: 56533eb9ac21ba0edf2244ad
title: Decrement a Number with JavaScript
challengeType: 1
videoUrl: ''
localeTitle: إنقاص رقم مع JavaScript
---
## Description
<section id="description"> يمكنك بسهولة <dfn>إنقاص</dfn> أو إنقاص متغير بواحد مع <code>--</code> المشغل. <code>i--;</code> يعادل <code>i = i - 1;</code> <strong>ملحوظة</strong> <br> يصبح الخط بأكمله <code>i--;</code> ، مما يلغي الحاجة إلى علامة المساواة. </section>
## Instructions
<section id="instructions"> تغيير الرمز لاستخدام <code>--</code> المشغل على <code>myVar</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن يساوي <code>myVar</code> <code>10</code>
testString: 'assert(myVar === 10, "<code>myVar</code> should equal <code>10</code>");'
- text: <code>myVar = myVar - 1;</code> يجب تغييرها
testString: 'assert(/var\s*myVar\s*=\s*11;\s*\/*.*\s*([-]{2}\s*myVar|myVar\s*[-]{2});/.test(code), "<code>myVar = myVar - 1;</code> should be changed");'
- text: استخدم <code>--</code> المشغل على <code>myVar</code>
testString: 'assert(/[-]{2}\s*myVar|myVar\s*[-]{2}/.test(code), "Use the <code>--</code> operator on <code>myVar</code>");'
- text: لا تغير الكود فوق الخط
testString: 'assert(/var myVar = 11;/.test(code), "Do not change code above the line");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var myVar = 11;
// Only change code below this line
myVar = myVar - 1;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,79 @@
---
id: 56bbb991ad1ed5201cd392d3
title: Delete Properties from a JavaScript Object
challengeType: 1
videoUrl: ''
localeTitle: حذف الخصائص من كائن JavaScript
---
## Description
<section id="description"> يمكننا أيضًا حذف خصائص من كائنات مثل: <code>delete ourDog.bark;</code> </section>
## Instructions
<section id="instructions"> حذف خاصية <code>&quot;tails&quot;</code> من <code>myDog</code> . يمكنك استخدام أي نقطة أو تدوين قوس. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: حذف الخاصية <code>&quot;tails&quot;</code> من <code>myDog</code> .
testString: 'assert(typeof myDog === "object" && myDog.tails === undefined, "Delete the property <code>"tails"</code> from <code>myDog</code>.");'
- text: لا تقم بتعديل إعداد <code>myDog</code>
testString: 'assert(code.match(/"tails": 1/g).length > 1, "Do not modify the <code>myDog</code> setup");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourDog = {
"name": "Camper",
"legs": 4,
"tails": 1,
"friends": ["everything!"],
"bark": "bow-wow"
};
delete ourDog.bark;
// Setup
var myDog = {
"name": "Happy Coder",
"legs": 4,
"tails": 1,
"friends": ["freeCodeCamp Campers"],
"bark": "woof"
};
// Only change code below this line.
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,61 @@
---
id: bd7993c9ca9feddfaeb7bdef
title: Divide One Decimal by Another with JavaScript
challengeType: 1
videoUrl: ''
localeTitle: قسّم رقم عشري واحد إلى آخر باستخدام جافا سكريبت
---
## Description
<section id="description"> الآن دعونا تقسيم واحد عشري بآخر. </section>
## Instructions
<section id="instructions"> غيِّر القيمة <code>0.0</code> بحيث يساوي ذلك <code>quotient</code> <code>2.2</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن يساوي <code>quotient</code> المتغير <code>2.2</code>
testString: 'assert(quotient === 2.2, "The variable <code>quotient</code> should equal <code>2.2</code>");'
- text: يجب عليك استخدام <code>/</code> المشغل لتقسيم 4.4 على 2
testString: 'assert(/4\.40*\s*\/\s*2\.*0*/.test(code), "You should use the <code>/</code> operator to divide 4.4 by 2");'
- text: يجب تعيين متغير القسمة مرة واحدة فقط
testString: 'assert(code.match(/quotient/g).length === 1, "The quotient variable should only be assigned once");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var quotient = 0.0 / 2.0; // Fix this line
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,59 @@
---
id: cf1111c1c11feddfaeb6bdef
title: Divide One Number by Another with JavaScript
challengeType: 1
videoUrl: ''
localeTitle: قسمة رقم واحد على آخر باستخدام JavaScript
---
## Description
<section id="description"> يمكننا أيضًا تقسيم رقم واحد بآخر. تستخدم جافا سكريبت الرمز <code>/</code> للقسمة. <p style=";text-align:right;direction:rtl"> <strong>مثال</strong> </p><blockquote style=";text-align:right;direction:rtl"> myVar = 16/2؛ // تعيين 8 </blockquote></section>
## Instructions
<section id="instructions"> تغيير <code>0</code> بحيث يكون <code>quotient</code> تساوي <code>2</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: اجعل <code>quotient</code> المتغير تساوي 2.
testString: 'assert(quotient === 2, "Make the variable <code>quotient</code> equal to 2.");'
- text: استخدم <code>/</code> المشغل
testString: 'assert(/\d+\s*\/\s*\d+/.test(code), "Use the <code>/</code> operator");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var quotient = 66 / 0;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,67 @@
---
id: 56533eb9ac21ba0edf2244b6
title: Escape Sequences in Strings
challengeType: 1
videoUrl: ''
localeTitle: الهروب من التسلسل في السلاسل
---
## Description
<section id="description"> لا تكون علامات الاقتباس هي الأحرف الوحيدة التي يمكن <dfn>تجنبها</dfn> داخل سلسلة. هناك سببان لاستخدام أحرف الهروب: أولاً هو السماح لك باستخدام الأحرف التي قد لا تتمكن من كتابتها ، مثل backspace. ثانيًا ، تسمح لك بتمثيل علامات الاقتباس المتعددة في سلسلة بدون إساءة تفسير جافا سكريبت لما تعنيه. تعلمنا هذا في التحدي السابق. <table class="table table-striped" style=";text-align:right;direction:rtl"><thead><tr><th> الشفرة </th><th> انتاج | </th></tr></thead><tbody><tr><td> <code>\&#39;</code> </td> <td> اقتباس واحد </td></tr><tr><td> <code>\&quot;</code> </td> <td> اقتباس مزدوج </td></tr><tr><td> <code>\\</code> </td> <td> مائل </td></tr><tr><td> <code>\n</code> </td> <td> خط جديد </td></tr><tr><td> <code>\r</code> </td> <td> إرجاع </td></tr><tr><td> <code>\t</code> </td> <td> التبويب </td></tr><tr><td> <code>\b</code> </td> <td> مسافة للخلف </td></tr><tr><td> <code>\f</code> </td> <td> نموذج تغذية </td></tr></tbody></table> <em>لاحظ أنه يجب أن يتم إبطال الخط المائل العكسي نفسه ليتم عرضه كشرطة مائلة للخلف (Backslash).</em> </section>
## Instructions
<section id="instructions"> قم بتعيين أسطر النص الثلاثة التالية في <code>myStr</code> متغير واحد باستخدام تسلسلات الهروب. <blockquote style=";text-align:right;direction:rtl"> السطر الأول <br> \السطر الثاني <br> ThirdLine </blockquote> ستحتاج إلى استخدام تسلسلات الهروب لإدراج أحرف خاصة بشكل صحيح. ستحتاج أيضًا إلى اتباع التباعد كما يبدو أعلاه ، مع عدم وجود مسافات بين تتابعات الهروب أو الكلمات. هنا هو النص مع تسلسل الهروب مكتوبة. <q>FirstLine <code>newline</code> <code>tab</code> <code>backslash</code> SecondLine <code>newline</code> ThirdLine</q> </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب ألا تحتوي <code>myStr</code> على أية مسافات
testString: 'assert(!/ /.test(myStr), "<code>myStr</code> should not contain any spaces");'
- text: يجب أن تحتوي <code>myStr</code> على السلاسل <code>FirstLine</code> و <code>SecondLine</code> و <code>ThirdLine</code> (تذكر حالة الحساسية)
testString: 'assert(/FirstLine/.test(myStr) && /SecondLine/.test(myStr) && /ThirdLine/.test(myStr), "<code>myStr</code> should contain the strings <code>FirstLine</code>, <code>SecondLine</code> and <code>ThirdLine</code> (remember case sensitivity)");'
- text: يجب أن يتبع <code>FirstLine</code> حرف السطر الجديد <code>\n</code>
testString: 'assert(/FirstLine\n/.test(myStr), "<code>FirstLine</code> should be followed by the newline character <code>\n</code>");'
- text: يجب أن تحتوي <code>myStr</code> على حرف tab <code>\t</code> يتبع حرف السطر الجديد
testString: 'assert(/\n\t/.test(myStr), "<code>myStr</code> should contain a tab character <code>\t</code> which follows a newline character");'
- text: <code>SecondLine</code> يجب أن يسبقه حرف مائل <code>\\</code>
testString: 'assert(/\SecondLine/.test(myStr), "<code>SecondLine</code> should be preceded by the backslash character <code>\\</code>");'
- text: يجب أن يكون هناك حرف سطر جديد بين <code>SecondLine</code> و <code>ThirdLine</code>
testString: 'assert(/SecondLine\nThirdLine/.test(myStr), "There should be a newline character between <code>SecondLine</code> and <code>ThirdLine</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var myStr; // Change this line
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,59 @@
---
id: 56533eb9ac21ba0edf2244b5
title: Escaping Literal Quotes in Strings
challengeType: 1
videoUrl: ''
localeTitle: الهروب من الأسعار الحرفيه في الاوتار
---
## Description
<section id="description"> عندما تقوم بتحديد سلسلة ، يجب أن تبدأ وتنتهي بعلامة اقتباس مفردة أو مزدوجة. ماذا يحدث عندما تحتاج إلى عرض سعر حرفي: <code>&quot;</code> أو <code>&#39;</code> داخل السلسلة الخاصة بك؟ في JavaScript ، يمكنك <dfn>الهروب</dfn> من اقتباس من اعتباره كنهاية لسلسلة الاقتباس عن طريق وضع خط <dfn>مائل عكسي</dfn> ( <code>\</code> ) أمام الاقتباس. <code>var sampleStr = &quot;Alan said, \&quot;Peter is learning JavaScript\&quot;.&quot;;</code> يشير هذا إلى جافا سكريبت بأن الاقتباس التالي ليس نهاية السلسلة ، بل يجب أن يظهر داخل السلسلة بدلاً من ذلك. لذلك إذا كنت ستطبعه إلى وحدة التحكم ، ستحصل على: <code>Alan said, &quot;Peter is learning JavaScript&quot;.</code> </section>
## Instructions
<section id="instructions"> استخدم <code>myStr</code> <dfn>المائلة العكسية</dfn> لتعيين سلسلة إلى متغير <code>myStr</code> بحيث إذا كنت <code>myStr</code> إلى وحدة التحكم ، سترى: <code>I am a &quot;double quoted&quot; string inside &quot;double quotes&quot;.</code> </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب عليك استخدام علامتي اقتباس مزدوجتين ( <code>&quot;</code> ) وأربعة علامات اقتباس مزدوجة ( <code>\&quot;</code> ).
testString: 'assert(code.match(/\\"/g).length === 4 && code.match(/[^\\]"/g).length === 2, "You should use two double quotes (<code>&quot;</code>) and four escaped double quotes (<code>&#92;&quot;</code>).");'
- text: 'يجب أن يحتوي myStr المتغير على السلسلة: <code>I am a &quot;double quoted&quot; string inside &quot;double quotes&quot;.</code>'
testString: 'assert(myStr === "I am a \"double quoted\" string inside \"double quotes\".", "Variable myStr should contain the string: <code>I am a "double quoted" string inside "double quotes".</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var myStr = ""; // Change this line
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,71 @@
---
id: bd7123c9c448eddfaeb5bdef
title: Find the Length of a String
challengeType: 1
videoUrl: ''
localeTitle: العثور على طول سلسلة
---
## Description
<section id="description"> يمكنك العثور على طول قيمة <code>String</code> بالكتابة. <code>.length</code> بعد متغير السلسلة أو سلسلة حرفية. <code>&quot;Alan Peter&quot;.length; // 10</code> على سبيل المثال ، إذا أنشأنا متغير <code>var firstName = &quot;Charles&quot;</code> ، يمكننا معرفة طول السلسلة <code>&quot;Charles&quot;</code> باستخدام الخاصية <code>firstName.length</code> . </section>
## Instructions
<section id="instructions"> استخدم خاصية <code>.length</code> لحساب عدد الأحرف في متغير <code>lastName</code> وتعيينه إلى <code>lastNameLength</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن تساوي <code>lastNameLength</code> ثمانية.
testString: 'assert((function(){if(typeof lastNameLength !== "undefined" && typeof lastNameLength === "number" && lastNameLength === 8){return true;}else{return false;}})(), "<code>lastNameLength</code> should be equal to eight.");'
- text: 'يجب أن تحصل على طول اسم <code>lastName</code> باستخدام <code>.length</code> مثل هذا: <code>lastName.length</code> .'
testString: 'assert((function(){if(code.match(/\.length/gi) && code.match(/\.length/gi).length >= 2 && code.match(/var lastNameLength \= 0;/gi) && code.match(/var lastNameLength \= 0;/gi).length >= 1){return true;}else{return false;}})(), "You should be getting the length of <code>lastName</code> by using <code>.length</code> like this: <code>lastName.length</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var firstNameLength = 0;
var firstName = "Ada";
firstNameLength = firstName.length;
// Setup
var lastNameLength = 0;
var lastName = "Lovelace";
// Only change code below this line.
lastNameLength = lastName;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,63 @@
---
id: 56533eb9ac21ba0edf2244ae
title: Finding a Remainder in JavaScript
challengeType: 1
videoUrl: ''
localeTitle: العثور على البقية في جافا سكريبت
---
## Description
<section id="description"> يعطي عامل <dfn>الباقي</dfn> <code>%</code> الباقي من قسم رقمين. <strong>مثال</strong> <blockquote style=";text-align:right;direction:rtl"> 5٪ 2 = 1 بسبب <br> Math.floor (5/2) = 2 (Quotient) <br> 2 * 2 = 4 <br> 5 - 4 = 1 (البقية) </blockquote> <strong>استعمال</strong> <br> في الرياضيات ، يمكن التحقق من الرقم ليكون زوجي أو فردي عن طريق فحص الجزء المتبقي من تقسيم الرقم إلى <code>2</code> . <blockquote style=";text-align:right;direction:rtl"> 17٪ 2 = 1 (17 فردي) <br> 48٪ 2 = 0 (48 حتى) </blockquote> <strong>ملحوظة</strong> <br> في بعض الأحيان يشار إلى مشغل <dfn>الباقي</dfn> بشكل غير صحيح باسم مشغل &quot;المعامل&quot;. وهي تشبه إلى حد بعيد المعامل ، ولكنها لا تعمل بشكل صحيح مع الأرقام السالبة. </section>
## Instructions
<section id="instructions"> حدد <code>remainder</code> مساويًا لما تبقى من <code>11</code> مقسومًا على <code>3</code> باستخدام عامل <dfn>الباقي</dfn> ( <code>%</code> ). </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب تهيئة المتغير <code>remainder</code>
testString: 'assert(/var\s+?remainder/.test(code), "The variable <code>remainder</code> should be initialized");'
- text: يجب أن تكون قيمة <code>remainder</code> <code>2</code>
testString: 'assert(remainder === 2, "The value of <code>remainder</code> should be <code>2</code>");'
- text: يجب عليك استخدام عامل التشغيل <code>%</code>
testString: 'assert(/\s+?remainder\s*?=\s*?.*%.*;/.test(code), "You should use the <code>%</code> operator");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Only change code below this line
var remainder;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,68 @@
---
id: cf1111c1c11feddfaeb9bdef
title: Generate Random Fractions with JavaScript
challengeType: 1
videoUrl: ''
localeTitle: توليد الكسور العشوائية مع جافا سكريبت
---
## Description
<section id="description"> الأرقام العشوائية مفيدة لإنشاء سلوك عشوائي. يحتوي JavaScript على دالة <code>Math.random()</code> التي تنشئ رقمًا عشريًا عشوائيًا بين <code>0</code> (شامل) وليس تمامًا <code>1</code> (خاص). وبالتالي ، يمكن أن يقوم <code>Math.random()</code> بإرجاع <code>0</code> ولكن لا يُرجع أبدًا <strong>ملاحظة</strong> <code>1</code> <br> مثل <a href="storing-values-with-the-assignment-operator" target="_blank">تخزين القيم مع عامل التشغيل المتساوي</a> ، سيتم حل جميع استدعاءات الدوال قبل تنفيذ عملية <code>return</code> ، حتى نتمكن من <code>return</code> قيمة الدالة <code>Math.random()</code> . </section>
## Instructions
<section id="instructions"> قم بتغيير <code>randomFraction</code> لإرجاع رقم عشوائي بدلاً من إرجاع <code>0</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>randomFraction</code> يجب إرجاع رقم عشوائي.
testString: 'assert(typeof randomFraction() === "number", "<code>randomFraction</code> should return a random number.");'
- text: يجب أن يكون الرقم الذي تم إرجاعه بواسطة <code>randomFraction</code> عشريًا.
testString: 'assert((randomFraction()+""). match(/\./g), "The number returned by <code>randomFraction</code> should be a decimal.");'
- text: يجب أن تستخدم <code>Math.random</code> لإنشاء الرقم العشري العشوائي.
testString: 'assert(code.match(/Math\.random/g).length >= 0, "You should be using <code>Math.random</code> to generate the random decimal number.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function randomFraction() {
// Only change code below this line.
return 0;
// Only change code above this line.
}
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,70 @@
---
id: cf1111c1c12feddfaeb1bdef
title: Generate Random Whole Numbers with JavaScript
challengeType: 1
videoUrl: ''
localeTitle: توليد أرقام كاملة عشوائية مع جافا سكريبت
---
## Description
<section id="description"> من الرائع أن نتمكن من توليد أرقام عشرية عشوائية ، ولكنها أكثر فائدة إذا استخدمناها لإنشاء أرقام صحيحة عشوائية. <ol style=";text-align:right;direction:rtl"><li style=";text-align:right;direction:rtl"> استخدم <code>Math.random()</code> لإنشاء عشري عشوائي. </li><li style=";text-align:right;direction:rtl"> اضرب هذا الرقم العشري العشوائي بـ <code>20</code> . </li><li style=";text-align:right;direction:rtl"> استخدم دالة أخرى ، <code>Math.floor()</code> الرقم إلى أقرب رقم <code>Math.floor()</code> له. </li></ol> تذكر أن <code>Math.random()</code> لا يمكنها أبدًا إرجاع <code>1</code> و ، نظرًا لأننا نقوم بالتقريب ، فمن المستحيل الحصول على <code>20</code> بالفعل. ستعطينا هذه التقنية عددًا صحيحًا بين <code>0</code> و <code>19</code> . وضع كل شيء معا ، وهذا هو ما تبدو عليه الكود لدينا: <code>Math.floor(Math.random() * 20);</code> نحن نطلق على <code>Math.random()</code> ، بضرب النتيجة بـ 20 ، ثم نمرر قيمة <code>Math.floor()</code> القيمة إلى أقرب رقم <code>Math.floor()</code> . </section>
## Instructions
<section id="instructions"> استخدم هذه التقنية لتوليد وإرجاع رقم صحيح عشوائي بين <code>0</code> و <code>9</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن تكون نتيجة <code>randomWholeNum</code> .
testString: 'assert(typeof randomWholeNum() === "number" && (function(){var r = randomWholeNum();return Math.floor(r) === r;})(), "The result of <code>randomWholeNum</code> should be a whole number.");'
- text: يجب أن تستخدم <code>Math.random</code> لإنشاء رقم عشوائي.
testString: 'assert(code.match(/Math.random/g).length > 1, "You should be using <code>Math.random</code> to generate a random number.");'
- text: يجب أن تضاعف نتيجة <code>Math.random</code> بمقدار 10 لجعله رقمًا بين صفر وتسعة.
testString: 'assert(code.match(/\s*?Math.random\s*?\(\s*?\)\s*?\*\s*?10[\D]\s*?/g) || code.match(/\s*?10\s*?\*\s*?Math.random\s*?\(\s*?\)\s*?/g), "You should have multiplied the result of <code>Math.random</code> by 10 to make it a number that is between zero and nine.");'
- text: يجب عليك استخدام <code>Math.floor</code> لإزالة الجزء العشري من الرقم.
testString: 'assert(code.match(/Math.floor/g).length > 1, "You should use <code>Math.floor</code> to remove the decimal part of the number.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var randomNumberBetween0and19 = Math.floor(Math.random() * 20);
function randomWholeNum() {
// Only change code below this line.
return Math.random();
}
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,80 @@
---
id: cf1111c1c12feddfaeb2bdef
title: Generate Random Whole Numbers within a Range
challengeType: 1
videoUrl: ''
localeTitle: توليد أرقام كاملة عشوائية داخل نطاق
---
## Description
<section id="description"> بدلاً من إنشاء رقم عشوائي بين الصفر ورقم معين كما فعلنا من قبل ، يمكننا إنشاء رقم عشوائي يقع ضمن نطاق من رقمين محددين. للقيام بذلك، ونحن سوف تحدد العدد الأدنى من <code>min</code> والحد الأقصى ل <code>max</code> . إليكم الصيغة التي سنستخدمها. خذ لحظة في قراءته وحاول فهم ما يفعله هذا الكود: <code>Math.floor(Math.random() * (max - min + 1)) + min</code> </section>
## Instructions
<section id="instructions"> قم بإنشاء دالة تسمى <code>randomRange</code> والتي تأخذ نطاق <code>myMin</code> و <code>myMax</code> وتقوم بإرجاع رقم عشوائي أكبر من أو يساوي <code>myMin</code> ، وهو أقل من أو يساوي <code>myMax</code> ، شامل. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن يكون العدد العشوائي الأدنى الذي يمكن إنشاؤه بواسطة <code>randomRange</code> مساوياً للحد الأدنى للرقم ، <code>myMin</code> .
testString: 'assert(calcMin === 5, "The lowest random number that can be generated by <code>randomRange</code> should be equal to your minimum number, <code>myMin</code>.");'
- text: يجب أن يكون الرقم العشوائي الأعلى الذي يمكن إنشاؤه بواسطة <code>randomRange</code> مساويا <code>myMax</code> عدد ممكن ، <code>myMax</code> .
testString: 'assert(calcMax === 15, "The highest random number that can be generated by <code>randomRange</code> should be equal to your maximum number, <code>myMax</code>.");'
- text: يجب أن يكون الرقم العشوائي الذي تم إنشاؤه بواسطة <code>randomRange</code> عددًا صحيحًا وليس عشريًا.
testString: 'assert(randomRange(0,1) % 1 === 0 , "The random number generated by <code>randomRange</code> should be an integer, not a decimal.");'
- text: <code>randomRange</code> يجب استخدام كل <code>myMax</code> و <code>myMin</code> ، وإرجاع رقم عشوائي في النطاق الخاص بك.
testString: 'assert((function(){if(code.match(/myMax/g).length > 1 && code.match(/myMin/g).length > 2 && code.match(/Math.floor/g) && code.match(/Math.random/g)){return true;}else{return false;}})(), "<code>randomRange</code> should use both <code>myMax</code> and <code>myMin</code>, and return a random number in your range.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
function ourRandomRange(ourMin, ourMax) {
return Math.floor(Math.random() * (ourMax - ourMin + 1)) + ourMin;
}
ourRandomRange(1, 9);
// Only change code below this line.
function randomRange(myMin, myMax) {
return 0; // Change this line
}
// Change these values to test your function
var myRandom = randomRange(5, 15);
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,109 @@
---
id: 56533eb9ac21ba0edf2244be
title: Global Scope and Functions
challengeType: 1
videoUrl: ''
localeTitle: النطاق العالمي والوظائف
---
## Description
<section id="description"> في JavaScript ، يشير <dfn>النطاق</dfn> إلى رؤية المتغيرات. المتغيرات التي يتم تعريفها خارج كتلة وظيفة لها نطاق <dfn>عالمي</dfn> . وهذا يعني أنه يمكن رؤيتها في أي مكان في شفرة جافا سكريبت. يتم إنشاء المتغيرات التي يتم استخدامها بدون الكلمة الأساسية <code>var</code> تلقائيًا في النطاق <code>global</code> . هذا يمكن أن يخلق عواقب غير مقصودة في مكان آخر في التعليمات البرمجية الخاصة بك أو عند تشغيل وظيفة مرة أخرى. يجب عليك دائما أن تعلن عن المتغيرات الخاصة بك مع <code>var</code> . </section>
## Instructions
<section id="instructions"> باستخدام <code>var</code> ، قم بتعريف متغير <code>global</code> <code>myGlobal</code> خارج أي وظيفة. قم بتهيئته بقيمة <code>10</code> . داخل الدالة <code>fun1</code> ، قم بتعيين <code>5</code> إلى <code>oopsGlobal</code> <strong><em>دون</em></strong> استخدام الكلمة الأساسية <code>var</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب تعريف <code>myGlobal</code>
testString: 'assert(typeof myGlobal != "undefined", "<code>myGlobal</code> should be defined");'
- text: يجب أن يكون ل <code>myGlobal</code> قيمة <code>10</code>
testString: 'assert(myGlobal === 10, "<code>myGlobal</code> should have a value of <code>10</code>");'
- text: يجب إعلان <code>myGlobal</code> باستخدام الكلمة الرئيسية <code>var</code>
testString: 'assert(/var\s+myGlobal/.test(code), "<code>myGlobal</code> should be declared using the <code>var</code> keyword");'
- text: يجب أن يكون <code>oopsGlobal</code> متغيرًا عامًا وله قيمة <code>5</code>
testString: 'assert(typeof oopsGlobal != "undefined" && oopsGlobal === 5, "<code>oopsGlobal</code> should be a global variable and have a value of <code>5</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Declare your variable here
function fun1() {
// Assign 5 to oopsGlobal Here
}
// Only change code above this line
function fun2() {
var output = "";
if (typeof myGlobal != "undefined") {
output += "myGlobal: " + myGlobal;
}
if (typeof oopsGlobal != "undefined") {
output += " oopsGlobal: " + oopsGlobal;
}
console.log(output);
}
```
</div>
### Before Test
<div id='js-setup'>
```js
var logOutput = "";
var originalConsole = console
function capture() {
var nativeLog = console.log;
console.log = function (message) {
logOutput = message;
if(nativeLog.apply) {
nativeLog.apply(originalConsole, arguments);
} else {
var nativeMsg = Array.prototype.slice.apply(arguments).join(' ');
nativeLog(nativeMsg);
}
};
}
function uncapture() {
console.log = originalConsole.log;
}
var oopsGlobal;
capture();
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,65 @@
---
id: 56533eb9ac21ba0edf2244c0
title: Global vs. Local Scope in Functions
challengeType: 1
videoUrl: ''
localeTitle: نطاق عالمي مقابل نطاق محلي في الوظائف
---
## Description
<section id="description"> من الممكن أن يكون لديك متغيرات <dfn>محلية</dfn> <dfn>وعالمية</dfn> تحمل نفس الاسم. عند القيام بذلك ، يأخذ المتغير <code>local</code> الأسبقية على المتغير <code>global</code> . في هذا المثال: <blockquote style=";text-align:right;direction:rtl"> var someVar = &quot;Hat&quot; ، <br> وظيفة myFun () { <br> var someVar = &quot;الرأس&quot; ؛ <br> عودة بعض <br> } </blockquote> ستقوم الدالة <code>myFun</code> بإرجاع <code>&quot;Head&quot;</code> لأن الإصدار <code>local</code> للمتغير موجود. </section>
## Instructions
<section id="instructions"> إضافة متغير محلي لوظيفة <code>myOutfit</code> لتجاوز قيمة <code>outerWear</code> مع <code>&quot;sweater&quot;</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: لا تغير قيمة <code>outerWear</code>
testString: 'assert(outerWear === "T-Shirt", "Do not change the value of the global <code>outerWear</code>");'
- text: يجب أن يعود <code>myOutfit</code> <code>&quot;sweater&quot;</code>
testString: 'assert(myOutfit() === "sweater", "<code>myOutfit</code> should return <code>"sweater"</code>");'
- text: لا تقم بتغيير بيان الإرجاع
testString: 'assert(/return outerWear/.test(code), "Do not change the return statement");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Setup
var outerWear = "T-Shirt";
function myOutfit() {
// Only change code below this line
// Only change code above this line
return outerWear;
}
myOutfit();
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,79 @@
---
id: 5664820f61c48e80c9fa476c
title: Golf Code
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(golfScore(4, 1) === "Hole-in-one!", "<code>golfScore(4, 1)</code> should return "Hole-in-one!"");'
- text: ''
testString: 'assert(golfScore(4, 2) === "Eagle", "<code>golfScore(4, 2)</code> should return "Eagle"");'
- text: ''
testString: 'assert(golfScore(5, 2) === "Eagle", "<code>golfScore(5, 2)</code> should return "Eagle"");'
- text: ''
testString: 'assert(golfScore(4, 3) === "Birdie", "<code>golfScore(4, 3)</code> should return "Birdie"");'
- text: ''
testString: 'assert(golfScore(4, 4) === "Par", "<code>golfScore(4, 4)</code> should return "Par"");'
- text: ''
testString: 'assert(golfScore(1, 1) === "Hole-in-one!", "<code>golfScore(1, 1)</code> should return "Hole-in-one!"");'
- text: ''
testString: 'assert(golfScore(5, 5) === "Par", "<code>golfScore(5, 5)</code> should return "Par"");'
- text: ''
testString: 'assert(golfScore(4, 5) === "Bogey", "<code>golfScore(4, 5)</code> should return "Bogey"");'
- text: ''
testString: 'assert(golfScore(4, 6) === "Double Bogey", "<code>golfScore(4, 6)</code> should return "Double Bogey"");'
- text: ''
testString: 'assert(golfScore(4, 7) === "Go Home!", "<code>golfScore(4, 7)</code> should return "Go Home!"");'
- text: ''
testString: 'assert(golfScore(5, 9) === "Go Home!", "<code>golfScore(5, 9)</code> should return "Go Home!"");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var names = ["Hole-in-one!", "Eagle", "Birdie", "Par", "Bogey", "Double Bogey", "Go Home!"];
function golfScore(par, strokes) {
// Only change code below this line
return "Change Me";
// Only change code above this line
}
// Change these values to test
golfScore(5, 4);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,66 @@
---
id: 56533eb9ac21ba0edf2244ac
title: Increment a Number with JavaScript
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(myVar === 88, "<code>myVar</code> should equal <code>88</code>");'
- text: ''
testString: 'assert(/var\s*myVar\s*=\s*87;\s*\/*.*\s*([+]{2}\s*myVar|myVar\s*[+]{2});/.test(code), "<code>myVar = myVar + 1;</code> should be changed");'
- text: ''
testString: 'assert(/[+]{2}\s*myVar|myVar\s*[+]{2}/.test(code), "Use the <code>++</code> operator");'
- text: ''
testString: 'assert(/var myVar = 87;/.test(code), "Do not change code above the line");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var myVar = 87;
// Only change code below this line
myVar = myVar + 1;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,60 @@
---
id: 56533eb9ac21ba0edf2244a9
title: Initializing Variables with the Assignment Operator
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(/var\s+a\s*=\s*9\s*/.test(code), "Initialize <code>a</code> to a value of <code>9</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourVar = 19;
// Only change code below this line
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,76 @@
---
id: 56533eb9ac21ba0edf2244db
title: Introducing Else If Statements
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(code.match(/else/g).length > 1, "You should have at least two <code>else</code> statements");'
- text: ''
testString: 'assert(code.match(/if/g).length > 1, "You should have at least two <code>if</code> statements");'
- text: ''
testString: 'assert(code.match(/if\s*\((.+)\)\s*\{[\s\S]+\}\s*else if\s*\((.+)\)\s*\{[\s\S]+\}\s*else\s*\{[\s\S]+\s*\}/), "You should have closing and opening curly braces for each condition in your if else statement");'
- text: ''
testString: 'assert(testElseIf(0) === "Smaller than 5", "<code>testElseIf(0)</code> should return "Smaller than 5"");'
- text: ''
testString: 'assert(testElseIf(5) === "Between 5 and 10", "<code>testElseIf(5)</code> should return "Between 5 and 10"");'
- text: ''
testString: 'assert(testElseIf(7) === "Between 5 and 10", "<code>testElseIf(7)</code> should return "Between 5 and 10"");'
- text: ''
testString: 'assert(testElseIf(10) === "Between 5 and 10", "<code>testElseIf(10)</code> should return "Between 5 and 10"");'
- text: ''
testString: 'assert(testElseIf(12) === "Greater than 10", "<code>testElseIf(12)</code> should return "Greater than 10"");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function testElseIf(val) {
if (val > 10) {
return "Greater than 10";
}
if (val < 5) {
return "Smaller than 5";
}
return "Between 5 and 10";
}
// Change this value to test
testElseIf(7);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,78 @@
---
id: 56533eb9ac21ba0edf2244da
title: Introducing Else Statements
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(code.match(/if/g).length === 1, "You should only have one <code>if</code> statement in the editor");'
- text: ''
testString: 'assert(/else/g.test(code), "You should use an <code>else</code> statement");'
- text: ''
testString: 'assert(testElse(4) === "5 or Smaller", "<code>testElse(4)</code> should return "5 or Smaller"");'
- text: ''
testString: 'assert(testElse(5) === "5 or Smaller", "<code>testElse(5)</code> should return "5 or Smaller"");'
- text: ''
testString: 'assert(testElse(6) === "Bigger than 5", "<code>testElse(6)</code> should return "Bigger than 5"");'
- text: ''
testString: 'assert(testElse(10) === "Bigger than 5", "<code>testElse(10)</code> should return "Bigger than 5"");'
- text: ''
testString: 'assert(/var result = "";/.test(code) && /return result;/.test(code), "Do not change the code above or below the lines.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function testElse(val) {
var result = "";
// Only change code below this line
if (val > 5) {
result = "Bigger than 5";
}
if (val <= 5) {
result = "5 or Smaller";
}
// Only change code above this line
return result;
}
// Change this value to test
testElse(4);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,69 @@
---
id: 56104e9e514f539506016a5c
title: Iterate Odd Numbers With a For Loop
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
- text: ''
testString: 'assert.deepEqual(myArray, [1,3,5,7,9], "<code>myArray</code> should equal <code>[1,3,5,7,9]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourArray = [];
for (var i = 0; i < 10; i += 2) {
ourArray.push(i);
}
// Setup
var myArray = [];
// Only change code below this line.
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,74 @@
---
id: 5675e877dbd60be8ad28edc6
title: Iterate Through an Array with a For Loop
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(code.match(/var.*?total\s*=\s*0.*?;/), "<code>total</code> should be declared and initialized to 0");'
- text: ''
testString: 'assert(total === 20, "<code>total</code> should equal 20");'
- text: ''
testString: 'assert(code.match(/for\s*\(/g).length > 1 && code.match(/myArr\s*\[/), "You should use a <code>for</code> loop to iterate through <code>myArr</code>");'
- text: ''
testString: 'assert(!code.match(/total[\s\+\-]*=\s*(\d(?!\s*[;,])|[1-9])/g), "Do not set <code>total</code> to 20 directly");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourArr = [ 9, 10, 11, 12];
var ourTotal = 0;
for (var i = 0; i < ourArr.length; i++) {
ourTotal += ourArr[i];
}
// Setup
var myArr = [ 2, 3, 4, 5, 6];
// Only change code below this line
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,70 @@
---
id: 5a2efd662fb457916e1fe604
title: Iterate with JavaScript Do...While Loops
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(code.match(/do/g), "You should be using a <code>do...while</code> loop for this.");'
- text: ''
testString: 'assert.deepEqual(myArray, [10], "<code>myArray</code> should equal <code>[10]</code>.");'
- text: ''
testString: 'assert.deepEqual(i, 11, "<code>i</code> should equal <code>11</code>");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Setup
var myArray = [];
var i = 10;
// Only change code below this line.
while (i < 5) {
myArray.push(i);
i++;
}
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,69 @@
---
id: cf1111c1c11feddfaeb5bdef
title: Iterate with JavaScript For Loops
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(code.match(/for\s*\(/g).length > 1, "You should be using a <code>for</code> loop for this.");'
- text: ''
testString: 'assert.deepEqual(myArray, [1,2,3,4,5], "<code>myArray</code> should equal <code>[1,2,3,4,5]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourArray = [];
for (var i = 0; i < 5; i++) {
ourArray.push(i);
}
// Setup
var myArray = [];
// Only change code below this line.
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,62 @@
---
id: cf1111c1c11feddfaeb1bdef
title: Iterate with JavaScript While Loops
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(code.match(/while/g), "You should be using a <code>while</code> loop for this.");'
- text: ''
testString: 'assert.deepEqual(myArray, [0,1,2,3,4], "<code>myArray</code> should equal <code>[0,1,2,3,4]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Setup
var myArray = [];
// Only change code below this line.
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,96 @@
---
id: 56533eb9ac21ba0edf2244bf
title: Local Scope and Functions
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(typeof myVar === "undefined", "No global <code>myVar</code> variable");'
- text: ''
testString: 'assert(/var\s+myVar/.test(code), "Add a local <code>myVar</code> variable");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function myLocalScope() {
'use strict'; // you shouldn't need to edit this line
console.log(myVar);
}
myLocalScope();
// Run and check the console
// myVar is not defined outside of myLocalScope
console.log(myVar);
// Now remove the console log line to pass the test
```
</div>
### Before Test
<div id='js-setup'>
```js
var logOutput = "";
var originalConsole = console
function capture() {
var nativeLog = console.log;
console.log = function (message) {
logOutput = message;
if(nativeLog.apply) {
nativeLog.apply(originalConsole, arguments);
} else {
var nativeMsg = Array.prototype.slice.apply(arguments).join(' ');
nativeLog(nativeMsg);
}
};
}
function uncapture() {
console.log = originalConsole.log;
}
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,64 @@
---
id: 5690307fddb111c6084545d7
title: Logical Order in If Else Statements
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(orderMyLogic(4) === "Less than 5", "<code>orderMyLogic(4)</code> should return "Less than 5"");'
- text: ''
testString: 'assert(orderMyLogic(6) === "Less than 10", "<code>orderMyLogic(6)</code> should return "Less than 10"");'
- text: ''
testString: 'assert(orderMyLogic(11) === "Greater than or equal to 10", "<code>orderMyLogic(11)</code> should return "Greater than or equal to 10"");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function orderMyLogic(val) {
if (val < 10) {
return "Less than 10";
} else if (val < 5) {
return "Less than 5";
} else {
return "Greater than or equal to 10";
}
}
// Change this value to test
orderMyLogic(7);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,70 @@
---
id: 56bbb991ad1ed5201cd392cc
title: Manipulate Arrays With pop()
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert((function(d){if(d[0][0] == "John" && d[0][1] === 23 && d[1] == undefined){return true;}else{return false;}})(myArray), "<code>myArray</code> should only contain <code>[["John", 23]]</code>.");'
- text: ''
testString: 'assert(/removedFromMyArray\s*=\s*myArray\s*.\s*pop\s*(\s*)/.test(code), "Use <code>pop()</code> on <code>myArray</code>");'
- text: ''
testString: 'assert((function(d){if(d[0] == "cat" && d[1] === 2 && d[2] == undefined){return true;}else{return false;}})(removedFromMyArray), "<code>removedFromMyArray</code> should only contain <code>["cat", 2]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourArray = [1,2,3];
var removedFromOurArray = ourArray.pop();
// removedFromOurArray now equals 3, and ourArray now equals [1,2]
// Setup
var myArray = [["John", 23], ["cat", 2]];
// Only change code below this line.
var removedFromMyArray;
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,65 @@
---
id: 56bbb991ad1ed5201cd392cb
title: Manipulate Arrays With push()
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert((function(d){if(d[2] != undefined && d[0][0] == "John" && d[0][1] === 23 && d[2][0] == "dog" && d[2][1] === 3 && d[2].length == 2){return true;}else{return false;}})(myArray), "<code>myArray</code> should now equal <code>[["John", 23], ["cat", 2], ["dog", 3]]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// Example
var ourArray = ["Stimpson", "J", "cat"];
ourArray.push(["happy", "joy"]);
// ourArray now equals ["Stimpson", "J", "cat", ["happy", "joy"]]
// Setup
var myArray = [["John", 23], ["cat", 2]];
// Only change code below this line.
```
</div>
### After Test
<div id='js-teardown'>
```js
console.info('after the test');
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

Some files were not shown because too many files have changed in this diff Show More