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,65 @@
---
id: 587d7da9367417b2b2512b67
title: Add Elements to the End of an Array Using concat Instead of push
challengeType: 1
videoUrl: ''
localeTitle: إضافة عناصر إلى نهاية صفيف باستخدام concat بدلاً من الضغط
---
## Description
<section id="description"> البرمجة الوظيفية هي كل شيء عن إنشاء واستخدام وظائف غير متحولة. قدم التحدي الأخير طريقة <code>concat</code> كطريقة لدمج المصفوفات في صف جديد دون تحوير المصفوفات الأصلية. قارن <code>concat</code> إلى طريقة <code>push</code> . يضيف <code>Push</code> عنصرًا إلى نهاية الصفيف نفسه الذي يطلق عليه ، والذي يحول ذلك الصفيف. إليك مثال على ذلك: <blockquote style=";text-align:right;direction:rtl"> var arr = [1، 2، 3]؛ <br> arr.push ([4، 5، 6])؛ <br> // arr يتم تغييرها إلى [1 ، 2 ، 3 ، [4 ، 5 ، 6]] <br> // ليس طريقة البرمجة الوظيفية </blockquote> يوفر <code>Concat</code> طريقة لإضافة عناصر جديدة إلى نهاية صفيف بدون أي تأثيرات جانبية متحولة. </section>
## Instructions
<section id="instructions"> تغيير الدالة <code>nonMutatingPush</code> بحيث يستخدم <code>concat</code> لإضافة <code>newItem</code> إلى نهاية <code>original</code> بدلاً من <code>push</code> . يجب على الدالة إرجاع صفيف. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن تستخدم التعليمات البرمجية الخاصة بك طريقة <code>concat</code> .
testString: 'assert(code.match(/\.concat/g), "Your code should use the <code>concat</code> method.");'
- text: يجب ألا تستخدم شفرتك طريقة <code>push</code> .
testString: 'assert(!code.match(/\.push/g), "Your code should not use the <code>push</code> method.");'
- text: يجب أن لا تتغير الصفيف <code>first</code> .
testString: 'assert(JSON.stringify(first) === JSON.stringify([1, 2, 3]), "The <code>first</code> array should not change.");'
- text: لا يجب تغيير الصفيف <code>second</code> .
testString: 'assert(JSON.stringify(second) === JSON.stringify([4, 5]), "The <code>second</code> array should not change.");'
- text: '<code>nonMutatingPush([1, 2, 3], [4, 5])</code> <code>[1, 2, 3, 4, 5]</code> .'
testString: 'assert(JSON.stringify(nonMutatingPush([1, 2, 3], [4, 5])) === JSON.stringify([1, 2, 3, 4, 5]), "<code>nonMutatingPush([1, 2, 3], [4, 5])</code> should return <code>[1, 2, 3, 4, 5]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function nonMutatingPush(original, newItem) {
// Add your code below this line
return original.push(newItem);
// Add your code above this line
}
var first = [1, 2, 3];
var second = [4, 5];
nonMutatingPush(first, second);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,69 @@
---
id: 587d7dab367417b2b2512b6d
title: Apply Functional Programming to Convert Strings to URL Slugs
challengeType: 1
videoUrl: ''
localeTitle: تطبيق برمجة وظيفية لتحويل السلاسل إلى Slug URL
---
## Description
<section id="description"> غطت التحديات الأخيرة عدة عدد من صفيفات السلسلة والصفيف المفيدة التي تتبع مبادئ البرمجة الوظيفية. لقد تعلمنا أيضًا عن <code>reduce</code> ، وهي طريقة قوية تستخدم لتقليل المشكلات إلى نماذج أبسط. من متوسطات الحوسبة إلى الفرز ، يمكن تحقيق أي عملية صفيف بتطبيقها. أذكر أن <code>map</code> <code>filter</code> هي حالات خاصة من <code>reduce</code> . دعونا ندمج ما تعلمناه لحل مشكلة عملية. تحتوي العديد من مواقع إدارة المحتوى (CMS) على عناوين وظيفة تتم إضافتها إلى جزء من عنوان URL لأغراض بسيطة للإشارة المرجعية. على سبيل المثال ، إذا كتبت منشورًا متوسطًا بعنوان &quot;Stop Using Reduce&quot; ، فمن المحتمل أن يكون لعنوان URL شكل من أشكال سلسلة العنوان فيه (&quot;... / stop-using-reduction&quot;). ربما تكون قد لاحظت هذا بالفعل على موقع freeCodeCamp. </section>
## Instructions
<section id="instructions"> املأ وظيفة <code>urlSlug</code> بحيث يحول <code>title</code> سلسلة ويعيد الإصدار <code>urlSlug</code> لعنوان URL. يمكنك استخدام أي من الطرق المغطاة في هذا القسم ، ولا تستخدم <code>replace</code> . فيما يلي المتطلبات: الإدخال عبارة عن سلسلة تحتوي على مسافات وكلمات ذات عناوين مكتوبة. الإخراج عبارة عن سلسلة تحتوي على مسافات بين الكلمات التي تم استبدالها بواصلة ( <code>-</code> ) يجب أن يكون الإخراج جميع الأحرف ذات الأحجام المنخفضة. يجب ألا يحتوي الإخراج على أية مسافات </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب ألا يتغير متغير <code>globalTitle</code> .
testString: 'assert(globalTitle === "Winter Is Coming", "The <code>globalTitle</code> variable should not change.");'
- text: يجب ألا تستخدم شفرتك طريقة <code>replace</code> لهذا التحدي.
testString: 'assert(!code.match(/\.replace/g), "Your code should not use the <code>replace</code> method for this challenge.");'
- text: يجب أن ترجع <code>urlSlug(&quot;Winter Is Coming&quot;)</code> <code>&quot;winter-is-coming&quot;</code> .
testString: 'assert(urlSlug("Winter Is Coming") === "winter-is-coming", "<code>urlSlug("Winter Is Coming")</code> should return <code>"winter-is-coming"</code>.");'
- text: يجب أن ترجع <code>urlSlug(&quot; Winter Is Coming&quot;)</code> <code>&quot;winter-is-coming&quot;</code> .
testString: 'assert(urlSlug(" Winter Is Coming") === "winter-is-coming", "<code>urlSlug(" Winter Is &nbsp;Coming")</code> should return <code>"winter-is-coming"</code>.");'
- text: <code>urlSlug(&quot;A Mind Needs Books Like A Sword Needs A Whetstone&quot;)</code> <code>&quot;a-mind-needs-books-like-a-sword-needs-a-whetstone&quot;</code> .
testString: 'assert(urlSlug("A Mind Needs Books Like A Sword Needs A Whetstone") === "a-mind-needs-books-like-a-sword-needs-a-whetstone", "<code>urlSlug("A Mind Needs Books Like A Sword Needs A Whetstone")</code> should return <code>"a-mind-needs-books-like-a-sword-needs-a-whetstone"</code>.");'
- text: يجب أن ترجع <code>urlSlug(&quot;Hold The Door&quot;)</code> <code>&quot;hold-the-door&quot;</code> .
testString: 'assert(urlSlug("Hold The Door") === "hold-the-door", "<code>urlSlug("Hold The Door")</code> should return <code>"hold-the-door"</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// the global variable
var globalTitle = "Winter Is Coming";
// Add your code below this line
function urlSlug(title) {
}
// Add your code above this line
var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,62 @@
---
id: 587d7b8e367417b2b2512b5e
title: Avoid Mutations and Side Effects Using Functional Programming
challengeType: 1
videoUrl: ''
localeTitle: تجنب الطفرات والآثار الجانبية باستخدام البرمجة الوظيفية
---
## Description
<section id="description"> إذا لم تكن قد برزت بالفعل ، كانت المشكلة في التحدي السابق مع استدعاء <code>splice</code> في وظيفة <code>tabClose()</code> . لسوء الحظ ، يغير <code>splice</code> الصفيف الأصلي الذي يتم استدعاؤه ، لذلك استعملت المكالمة الثانية له مصفوفة معدلة ، وأعطت نتائج غير متوقعة. هذا مثال صغير لنمط أكبر بكثير - تقوم باستدعاء وظيفة على متغير أو صفيف أو كائن ، وتقوم الوظيفة بتغيير المتغير أو شيء ما في الكائن. أحد المبادئ الأساسية للبرمجة الوظيفية هو عدم تغيير الأشياء. التغييرات تؤدي إلى البق. من السهل منع الأخطاء مع العلم أن وظائفك لا تغير أي شيء ، بما في ذلك وسائط الدالة أو أي متغير عالمي. لم يكن للمثال السابق أي عمليات معقدة ولكن طريقة <code>splice</code> غيرت الصفيف الأصلي ، وأدت إلى خلل. أذكر أنه في البرمجة الوظيفية ، وتغيير أو تغيير الأمور يسمى <code>mutation</code> ، ويسمى النتيجة <code>side effect</code> . من الناحية المثالية ، ينبغي أن تكون <code>pure function</code> ، بمعنى أنها لا تسبب أي آثار جانبية. دعونا نحاول إتقان هذا الانضباط وعدم تغيير أي متغير أو كائن في الكود. </section>
## Instructions
<section id="instructions"> ملء رمز لوظيفة <code>incrementer</code> بحيث تقوم بإرجاع قيمة المتغير العالمي <code>fixedValue</code> بنسبة واحد. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: لا يجب أن تقوم الدالة <code>incrementer</code> بتغيير قيمة <code>fixedValue</code> .
testString: 'assert(fixedValue === 4, "Your function <code>incrementer</code> should not change the value of <code>fixedValue</code>.");'
- text: يجب أن ترجع الدالة <code>incrementer</code> الخاص بك قيمة أكبر من قيمة <code>fixedValue</code> .
testString: 'assert(newValue === 5, "Your <code>incrementer</code> function should return a value that is one larger than the <code>fixedValue</code> value.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// the global variable
var fixedValue = 4;
function incrementer () {
// Add your code below this line
// Add your code above this line
}
var newValue = incrementer(); // Should equal 5
console.log(fixedValue); // Should print 4
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,65 @@
---
id: 587d7daa367417b2b2512b6c
title: Combine an Array into a String Using the join Method
challengeType: 1
videoUrl: ''
localeTitle: دمج صفيف في سلسلة باستخدام طريقة الانضمام
---
## Description
<section id="description"> على <code>join</code> يستخدم طريقة للانضمام إلى عناصر من مجموعة معا لخلق سلسلة. يستغرق وسيطة عن المحدد الذي يتم استخدامه لفصل عناصر الصفيف في السلسلة. إليك مثال على ذلك: <blockquote style=";text-align:right;direction:rtl"> var arr = [&quot;Hello&quot;، &quot;World&quot;<br> var str = arr.join (&quot;&quot;<br> // يعين str إلى &quot;Hello World&quot; </blockquote></section>
## Instructions
<section id="instructions"> استخدم طريقة <code>join</code> (من بين آخرين) داخل الدالة <code>sentensify</code> لإنشاء جملة من الكلمات في <code>str</code> السلسلة. يجب على الدالة إرجاع سلسلة. على سبيل المثال ، سيتم تحويل &quot;I-like-Star-Wars&quot; إلى &quot;I like Star Wars&quot;. لهذا التحدي ، لا تستخدم طريقة <code>replace</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب استخدام التعليمات البرمجية لل <code>join</code> الأسلوب.
testString: 'assert(code.match(/\.join/g), "Your code should use the <code>join</code> method.");'
- text: يجب ألا تستخدم الشفرة طريقة <code>replace</code> .
testString: 'assert(!code.match(/\.replace/g), "Your code should not use the <code>replace</code> method.");'
- text: <code>sentensify(&quot;May-the-force-be-with-you&quot;)</code> يجب إرجاع سلسلة.
testString: 'assert(typeof sentensify("May-the-force-be-with-you") === "string", "<code>sentensify("May-the-force-be-with-you")</code> should return a string.");'
- text: <code>sentensify(&quot;May-the-force-be-with-you&quot;)</code> يجب أن ترجع <code>&quot;May the force be with you&quot;</code> .
testString: 'assert(sentensify("May-the-force-be-with-you") === "May the force be with you", "<code>sentensify("May-the-force-be-with-you")</code> should return <code>"May the force be with you"</code>.");'
- text: <code>sentensify(&quot;The.force.is.strong.with.this.one&quot;)</code> يجب أن ترجع <code>&quot;The force is strong with this one&quot;</code> .
testString: 'assert(sentensify("The.force.is.strong.with.this.one") === "The force is strong with this one", "<code>sentensify("The.force.is.strong.with.this.one")</code> should return <code>"The force is strong with this one"</code>.");'
- text: '<code>sentensify(&quot;There,has,been,an,awakening&quot;)</code> يجب أن تعود <code>&quot;There has been an awakening&quot;</code> .'
testString: 'assert(sentensify("There,has,been,an,awakening") === "There has been an awakening", "<code>sentensify("There,has,been,an,awakening")</code> should return <code>"There has been an awakening"</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function sentensify(str) {
// Add your code below this line
// Add your code above this line
}
sentensify("May-the-force-be-with-you");
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,63 @@
---
id: 587d7da9367417b2b2512b66
title: Combine Two Arrays Using the concat Method
challengeType: 1
videoUrl: ''
localeTitle: الجمع بين اثنين من المصفوفات باستخدام طريقة concat
---
## Description
<section id="description"> يعني <code>Concatenation</code> للانضمام إلى العناصر من طرف إلى آخر. تقدم JavaScript طريقة <code>concat</code> لكل من السلاسل والمصفوفات التي تعمل بنفس الطريقة. بالنسبة إلى المصفوفات ، يتم استدعاء هذه الطريقة على واحد ، ثم يتم توفير مجموعة أخرى كوسيطة <code>concat</code> ، والتي يتم إضافتها إلى نهاية الصفيف الأول. تقوم بإرجاع صفيف جديد ولا يتم تغيير أي من المصفوفات الأصلية. إليك مثال على ذلك: <blockquote style=";text-align:right;direction:rtl"> [1 ، 2 ، 3] .concat ([4 ، 5 ، 6]) ؛ <br> // إرجاع مصفوفة جديدة [1 ، 2 ، 3 ، 4 ، 5 ، 6] </blockquote></section>
## Instructions
<section id="instructions"> استخدام <code>concat</code> الأسلوب في <code>nonMutatingConcat</code> وظيفة لسلسلة <code>attach</code> إلى نهاية <code>original</code> . يجب أن تقوم الدالة بإرجاع الصفيف المتسلسل. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن تستخدم التعليمات البرمجية الخاصة بك طريقة <code>concat</code> .
testString: 'assert(code.match(/\.concat/g), "Your code should use the <code>concat</code> method.");'
- text: يجب أن لا تتغير الصفيف <code>first</code> .
testString: 'assert(JSON.stringify(first) === JSON.stringify([1, 2, 3]), "The <code>first</code> array should not change.");'
- text: لا يجب تغيير الصفيف <code>second</code> .
testString: 'assert(JSON.stringify(second) === JSON.stringify([4, 5]), "The <code>second</code> array should not change.");'
- text: '<code>nonMutatingConcat([1, 2, 3], [4, 5])</code> <code>[1, 2, 3, 4, 5]</code> .'
testString: 'assert(JSON.stringify(nonMutatingConcat([1, 2, 3], [4, 5])) === JSON.stringify([1, 2, 3, 4, 5]), "<code>nonMutatingConcat([1, 2, 3], [4, 5])</code> should return <code>[1, 2, 3, 4, 5]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function nonMutatingConcat(original, attach) {
// Add your code below this line
// Add your code above this line
}
var first = [1, 2, 3];
var second = [4, 5];
nonMutatingConcat(first, second);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,65 @@
---
id: 587d7b8f367417b2b2512b62
title: Implement map on a Prototype
challengeType: 1
videoUrl: ''
localeTitle: تنفيذ الخريطة على نموذج أولي
---
## Description
<section id="description"> كما رأيت من تطبيق <code>Array.prototype.map()</code> ، أو ببساطة <code>map()</code> وقت سابق ، فإن طريقة <code>map</code> ترجع مصفوفة بنفس الطول <code>Array.prototype.map()</code> تم الاتصال به. كما أنه لا يغير الصفيف الأصلي ، طالما أن وظيفة رد الاتصال لا. بعبارة أخرى ، <code>map</code> هي وظيفة نقية ، ويعتمد ناتجها فقط على مدخلاته. بالإضافة إلى ذلك ، فإنه يأخذ وظيفة أخرى كحجة لها. فإنه يعلمنا الكثير عن <code>map</code> لمحاولة تنفيذ نسخة منه أن يتصرف تماما مثل <code>Array.prototype.map()</code> مع <code>for</code> حلقة أو <code>Array.prototype.forEach()</code> . ملاحظة: يسمح للوظيفة النقية بتغيير المتغيرات المحلية المحددة في نطاقها ، على الرغم من أنه من الأفضل تجنب ذلك أيضًا. </section>
## Instructions
<section id="instructions"> اكتب <code>Array.prototype.myMap()</code> الخاص بك ، والتي يجب أن تتصرف تمامًا مثل <code>Array.prototype.map()</code> . يمكنك استخدام حلقة <code>for</code> أو طريقة <code>forEach</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: 'يجب أن تساوي <code>new_s</code> <code>[46, 130, 196, 10]</code> .'
testString: 'assert(JSON.stringify(new_s) === JSON.stringify([46, 130, 196, 10]), "<code>new_s</code> should equal <code>[46, 130, 196, 10]</code>.");'
- text: يجب ألا تستخدم شفرتك طريقة <code>map</code> .
testString: 'assert(!code.match(/\.map/g), "Your code should not use the <code>map</code> method.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// the global Array
var s = [23, 65, 98, 5];
Array.prototype.myMap = function(callback){
var newArray = [];
// Add your code below this line
// Add your code above this line
return newArray;
};
var new_s = s.myMap(function(item){
return item * 2;
});
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,65 @@
---
id: 587d7b8f367417b2b2512b64
title: Implement the filter Method on a Prototype
challengeType: 1
videoUrl: ''
localeTitle: تنفيذ مرشح طريقة على النموذج
---
## Description
<section id="description"> من شأنه أن يعلمنا الكثير عن طريقة <code>filter</code> إذا حاولنا تنفيذ إصدار منه يتصرف تمامًا مثل <code>Array.prototype.filter()</code> . يمكن استخدام حلقة <code>for</code> أو <code>Array.prototype.forEach()</code> . ملاحظة: يسمح للوظيفة النقية بتغيير المتغيرات المحلية المحددة في نطاقها ، على الرغم من أنه من الأفضل تجنب ذلك أيضًا. </section>
## Instructions
<section id="instructions"> اكتب <code>Array.prototype.myFilter()</code> الخاص بك ، والتي يجب أن تتصرف تمامًا مثل <code>Array.prototype.filter()</code> . يمكنك استخدام حلقة <code>for</code> أو الأسلوب <code>Array.prototype.forEach()</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: 'يجب أن تساوي <code>new_s</code> <code>[23, 65, 5]</code> .'
testString: 'assert(JSON.stringify(new_s) === JSON.stringify([23, 65, 5]), "<code>new_s</code> should equal <code>[23, 65, 5]</code>.");'
- text: يجب ألا تستخدم الشفرة طريقة <code>filter</code> .
testString: 'assert(!code.match(/\.filter/g), "Your code should not use the <code>filter</code> method.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// the global Array
var s = [23, 65, 98, 5];
Array.prototype.myFilter = function(callback){
var newArray = [];
// Add your code below this line
// Add your code above this line
return newArray;
};
var new_s = s.myFilter(function(item){
return item % 2 === 1;
});
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,61 @@
---
id: 587d7dab367417b2b2512b70
title: Introduction to Currying and Partial Application
challengeType: 1
videoUrl: ''
localeTitle: مقدمة في التجلي والتطبيق الجزئي
---
## Description
<section id="description"> إن <code>arity</code> الوظيفة هو عدد الحجج التي يتطلبها. تعني وظيفة <code>Currying</code> دالة تحويل دالة N <code>arity</code> إلى N دالتي <code>arity</code> 1. وبعبارة أخرى ، فإنها تعيد هيكلة إحدى الدالتين بحيث تأخذ إحدى الحجة ، ثم ترجع دالة أخرى تأخذ الحجة التالية ، وهكذا. إليك مثال على ذلك: <blockquote style=";text-align:right;direction:rtl"> // غير بالكاري وظيفة <br> وظيفة غير مضمنة (x، y) { <br> ارجع x + y؛ <br> } <br><br> // وظيفة الكاري <br> الوظيفة curried (x) { <br> وظيفة الإرجاع (y) { <br> ارجع x + y؛ <br> } <br> } <br> curried (1) (2) // Returns 3 </blockquote> هذا مفيد في البرنامج الخاص بك إذا كنت لا تستطيع توفير جميع الوسائط إلى وظيفة في وقت واحد. يمكنك حفظ كل استدعاء دالة في متغير ، والذي سيحافظ على مرجع الدالة المرتجعة الذي يأخذ الوسيطة التالية عندما تكون متاحة. في ما يلي مثال على ذلك باستخدام وظيفة <code>curried</code> في المثال أعلاه: <blockquote style=";text-align:right;direction:rtl"> // استدعاء وظيفة بالكاري في أجزاء: <br> var funcForY = curried (1)؛ <br> console.log (funcForY (2))؛ // المطبوعات 3 </blockquote> وبالمثل ، يمكن وصف <code>partial application</code> على أنه تطبيق عدد قليل من الوسيطات على إحدى الوظائف في وقت ما وإرجاع وظيفة أخرى يتم تطبيقها على مزيد من الوسيطات. إليك مثال على ذلك: <blockquote style=";text-align:right;direction:rtl"> // وظيفة محايدة <br> وظيفة غير متحيزة (x، y، z) { <br> ارجع x + y + z؛ <br> } <br> var partialFn = impartial.bind (هذا ، 1 ، 2) ؛ <br> partialFn (10)؛ // إرجاع 13 </blockquote></section>
## Instructions
<section id="instructions"> املأ جسم وظيفة <code>add</code> بحيث يستخدم currying لإضافة المعلمات <code>x</code> و <code>y</code> و <code>z</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: <code>add(10)(20)(30)</code> يجب أن ترجع <code>60</code> .
testString: 'assert(add(10)(20)(30) === 60, "<code>add(10)(20)(30)</code> should return <code>60</code>.");'
- text: <code>add(1)(2)(3)</code> يجب أن ترجع <code>6</code> .
testString: 'assert(add(1)(2)(3) === 6, "<code>add(1)(2)(3)</code> should return <code>6</code>.");'
- text: <code>add(11)(22)(33)</code> يجب أن ترجع <code>66</code> .
testString: 'assert(add(11)(22)(33) === 66, "<code>add(11)(22)(33)</code> should return <code>66</code>.");'
- text: يجب أن تتضمن شفرتك عبارة نهائية تُرجع <code>x + y + z</code> .
testString: 'assert(code.match(/[xyz]\s*?\+\s*?[xyz]\s*?\+\s*?[xyz]/g), "Your code should include a final statement that returns <code>x + y + z</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function add(x) {
// Add your code below this line
// Add your code above this line
}
add(10)(20)(30);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,79 @@
---
id: 587d7b8d367417b2b2512b5b
title: Learn About Functional Programming
challengeType: 1
videoUrl: ''
localeTitle: تعرف على برمجة وظيفية
---
## Description
<section id="description"> البرمجة الوظيفية هي أسلوب برمجة حيث الحلول عبارة عن وظائف بسيطة ومعزولة دون أي آثار جانبية خارج نطاق الوظيفة. <code>INPUT -&gt; PROCESS -&gt; OUTPUT</code> البرمجة الوظيفية <code>INPUT -&gt; PROCESS -&gt; OUTPUT</code> حول: 1) وظائف معزولة - لا يوجد اعتماد على حالة البرنامج ، والذي يتضمن متغيرات عامة قابلة للتغيير 2) وظائف نقية - نفس المدخلات تعطي دائما نفس الناتج 3) يتم التحكم بعناية بالوظائف ذات الآثار الجانبية المحدودة - أي تغييرات ، أو طفرات ، إلى حالة البرنامج خارج الوظيفة </section>
## Instructions
<section id="instructions"> أعضاء freeCodeCamp يحدث أن يحب الشاي. في محرر رمز، و <code>prepareTea</code> و <code>getTea</code> يتم تعريف وظائف بالفعل بالنسبة لك. استدعاء وظيفة <code>getTea</code> للحصول على 40 كوب من الشاي للفريق ، وتخزينها في متغير <code>tea4TeamFCC</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(tea4TeamFCC.length === 40, "The <code>tea4TeamFCC</code> variable should hold 40 cups of tea for the team.");'
- text: يجب أن يعقد المتغير <code>tea4TeamFCC</code> أكواب الشاي الأخضر.
testString: 'assert(tea4TeamFCC[0] === "greenTea", "The <code>tea4TeamFCC</code> variable should hold cups of green tea.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
/**
* A long process to prepare tea.
* @return {string} A cup of tea.
**/
const prepareTea = () => 'greenTea';
/**
* Get given number of cups of tea.
* @param {number} numOfCups Number of required cups of tea.
* @return {Array<string>} Given amount of tea cups.
**/
const getTea = (numOfCups) => {
const teaCups = [];
for(let cups = 1; cups <= numOfCups; cups += 1) {
const teaCup = prepareTea();
teaCups.push(teaCup);
}
return teaCups;
};
// Add your code below this line
const tea4TeamFCC = null; // :(
// Add your code above this line
console.log(tea4TeamFCC);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,64 @@
---
id: 587d7b8e367417b2b2512b5f
title: Pass Arguments to Avoid External Dependence in a Function
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(fixedValue === 4, "Your function <code>incrementer</code> should not change the value of <code>fixedValue</code>.");'
- text: ''
testString: 'assert(code.match(/function\s+?incrementer\s*?\(.+?\)/g), "Your <code>incrementer</code> function should take a parameter.");'
- text: ''
testString: 'assert(newValue === 5, "Your <code>incrementer</code> function should return a value that is one larger than the <code>fixedValue</code> value.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// the global variable
var fixedValue = 4;
// Add your code below this line
function incrementer () {
// Add your code above this line
}
var newValue = incrementer(fixedValue); // Should equal 5
console.log(fixedValue); // Should print 4
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,86 @@
---
id: 587d7b8f367417b2b2512b60
title: Refactor Global Variables Out of Functions
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(JSON.stringify(bookList) === JSON.stringify(["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]), "<code>bookList</code> should not change and still equal <code>["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]</code>.");'
- text: ''
testString: 'assert(JSON.stringify(newBookList) === JSON.stringify(["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]), "<code>newBookList</code> should equal <code>["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]</code>.");'
- text: ''
testString: 'assert(JSON.stringify(newerBookList) === JSON.stringify(["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]), "<code>newerBookList</code> should equal <code>["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"]</code>.");'
- text: ''
testString: 'assert(JSON.stringify(newestBookList) === JSON.stringify(["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]), "<code>newestBookList</code> should equal <code>["The Hound of the Baskervilles", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae", "A Brief History of Time"]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// the global variable
var bookList = ["The Hound of the Baskervilles", "On The Electrodynamics of Moving Bodies", "Philosophiæ Naturalis Principia Mathematica", "Disquisitiones Arithmeticae"];
/* This function should add a book to the list and return the list */
// New parameters should come before the bookName one
// Add your code below this line
function add (bookName) {
return bookList.push(bookName);
// Add your code above this line
}
/* This function should remove a book from the list and return the list */
// New parameters should come before the bookName one
// Add your code below this line
function remove (bookName) {
if (bookList.indexOf(bookName) >= 0) {
return bookList.splice(0, 1, bookName);
// Add your code above this line
}
}
var newBookList = add(bookList, 'A Brief History of Time');
var newerBookList = remove(bookList, 'On The Electrodynamics of Moving Bodies');
var newestBookList = remove(add(bookList, 'A Brief History of Time'), 'On The Electrodynamics of Moving Bodies');
console.log(bookList);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,62 @@
---
id: 9d7123c8c441eeafaeb5bdef
title: Remove Elements from an Array Using slice Instead of splice
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(code.match(/\.slice/g), "Your code should use the <code>slice</code> method.");'
- text: ''
testString: 'assert(!code.match(/\.splice/g), "Your code should not use the <code>splice</code> method.");'
- text: ''
testString: 'assert(JSON.stringify(inputCities) === JSON.stringify(["Chicago", "Delhi", "Islamabad", "London", "Berlin"]), "The <code>inputCities</code> array should not change.");'
- text: ''
testString: 'assert(JSON.stringify(nonMutatingSplice(["Chicago", "Delhi", "Islamabad", "London", "Berlin"])) === JSON.stringify(["Chicago", "Delhi", "Islamabad"]), "<code>nonMutatingSplice(["Chicago", "Delhi", "Islamabad", "London", "Berlin"])</code> should return <code>["Chicago", "Delhi", "Islamabad"]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function nonMutatingSplice(cities) {
// Add your code below this line
return cities.splice(3);
// Add your code above this line
}
var inputCities = ["Chicago", "Delhi", "Islamabad", "London", "Berlin"];
nonMutatingSplice(inputCities);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,62 @@
---
id: 587d7da9367417b2b2512b6a
title: Return a Sorted Array Without Changing the Original Array
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
<section id="instructions"> استخدم طريقة <code>sort</code> في الدالة <code>nonMutatingSort</code> لفرز عناصر صفيف بترتيب تصاعدي. يجب أن ترجع الدالة صفيفًا جديدًا ولا يتم <code>globalArray</code> متغير <code>globalArray</code> . </section>
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(code.match(/\.sort/g), "Your code should use the <code>sort</code> method.");'
- text: ''
testString: 'assert(code.match(/\.concat/g), "Your code should use the <code>concat</code> method.");'
- text: يجب ألا يتغير متغير <code>globalArray</code> .
testString: 'assert(JSON.stringify(globalArray) === JSON.stringify([5, 6, 3, 2, 9]), "The <code>globalArray</code> variable should not change.");'
- text: ''
testString: 'assert(JSON.stringify(nonMutatingSort(globalArray)) === JSON.stringify([2, 3, 5, 6, 9]), "<code>nonMutatingSort(globalArray)</code> should return <code>[2, 3, 5, 6, 9]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
var globalArray = [5, 6, 3, 2, 9];
function nonMutatingSort(arr) {
// Add your code below this line
// Add your code above this line
}
nonMutatingSort(globalArray);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,64 @@
---
id: 587d7b90367417b2b2512b65
title: Return Part of an Array Using the slice Method
challengeType: 1
videoUrl: ''
localeTitle: عودة جزء من صفيف باستخدام طريقة شريحة
---
## Description
<section id="description"> ترجع طريقة <code>slice</code> نسخة من عناصر معينة لصفيف. يمكن أن يستغرق الأمر اثنين من الحجج ، الأول يعطي مؤشر من أين تبدأ شريحة ، والثاني هو مؤشر لمكان إنهاء الشريحة (وهو غير شامل). إذا لم يتم توفير الوسيطات ، فسيكون الإعداد الافتراضي هو البدء في بداية المصفوفة حتى النهاية ، وهي طريقة سهلة لعمل نسخة من الصفيف بأكمله. لا تقوم طريقة <code>slice</code> بتحويل الصفيف الأصلي ، بل تقوم بإرجاع واحدة جديدة. إليك مثال على ذلك: <blockquote style=";text-align:right;direction:rtl"> var arr = [&quot;Cat&quot;، &quot;Dog&quot;، &quot;Tiger&quot;، &quot;Zebra&quot;<br> var newArray = arr.slice (1، 3)؛ <br> // يعين NewArray to [&quot;Dog&quot;، &quot;Tiger&quot;] </blockquote></section>
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن تستخدم شفرتك طريقة <code>slice</code> .
testString: 'assert(code.match(/\.slice/g), "Your code should use the <code>slice</code> method.");'
- text: ''
testString: 'assert(JSON.stringify(inputAnim) === JSON.stringify(["Cat", "Dog", "Tiger", "Zebra", "Ant"]), "The <code>inputAnim</code> variable should not change.");'
- text: ''
testString: 'assert(JSON.stringify(sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 3)) === JSON.stringify(["Dog", "Tiger"]), "<code>sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 3)</code> should return <code>["Dog", "Tiger"]</code>.");'
- text: '<code>sliceArray([&quot;Cat&quot;, &quot;Dog&quot;, &quot;Tiger&quot;, &quot;Zebra&quot;, &quot;Ant&quot;], 0, 1)</code> يجب أن تعود <code>[&quot;Cat&quot;]</code> .'
testString: 'assert(JSON.stringify(sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 0, 1)) === JSON.stringify(["Cat"]), "<code>sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 0, 1)</code> should return <code>["Cat"]</code>.");'
- text: '<code>sliceArray([&quot;Cat&quot;, &quot;Dog&quot;, &quot;Tiger&quot;, &quot;Zebra&quot;, &quot;Ant&quot;], 1, 4)</code> يجب أن تعود <code>[&quot;Dog&quot;, &quot;Tiger&quot;, &quot;Zebra&quot;]</code> .'
testString: 'assert(JSON.stringify(sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 4)) === JSON.stringify(["Dog", "Tiger", "Zebra"]), "<code>sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 4)</code> should return <code>["Dog", "Tiger", "Zebra"]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function sliceArray(anim, beginSlice, endSlice) {
// Add your code below this line
// Add your code above this line
}
var inputAnim = ["Cat", "Dog", "Tiger", "Zebra", "Ant"];
sliceArray(inputAnim, 1, 3);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,61 @@
---
id: 587d7da9367417b2b2512b69
title: Sort an Array Alphabetically using the sort Method
challengeType: 1
videoUrl: ''
localeTitle: فرز صفيف أبجديا باستخدام طريقة الفرز
---
## Description
<section id="description"> يقوم أسلوب <code>sort</code> بفرز عناصر المصفوفة وفقًا لوظيفة رد الاتصال. فمثلا: <blockquote style=";text-align:right;direction:rtl"> function ascendingOrder (arr) { <br> return arr.sort (function (a، b) { <br> عودة a - b؛ <br> })؛ <br> } <br> تصاعدي ([1 ، 5 ، 2 ، 3 ، 4]) ؛ <br> // إرجاع [1 ، 2 ، 3 ، 4 ، 5] <br><br> function reverseAlpha (arr) { <br> return arr.sort (function (a، b) { <br> ارجع &lt;<br> })؛ <br> } <br> reverseAlpha ([&#39;l&#39;، &#39;h&#39;، &#39;z&#39;، &#39;b&#39;، &#39;s&#39;])؛ <br> // Returns [&#39;z&#39;، &#39;s&#39;، &#39;l&#39;، &#39;h&#39;، &#39;b&#39;] </blockquote> ملاحظة: يتم تشجيعه على توفير وظيفة رد اتصال لتحديد كيفية فرز عناصر المصفوفة. طريقة الفرز الافتراضية لجافا سكريبت هي عن طريق سلسلة قيمة نقطة Unicode ، والتي قد ترجع نتائج غير متوقعة. </section>
## Instructions
<section id="instructions"> استخدم طريقة <code>sort</code> في الدالة <code>alphabeticalOrder</code> لفرز عناصر <code>arr</code> حسب الترتيب الأبجدي. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن تستخدم التعليمات البرمجية الخاصة بك طريقة <code>sort</code> .
testString: 'assert(code.match(/\.sort/g), "Your code should use the <code>sort</code> method.");'
- text: '<code>alphabeticalOrder([&quot;a&quot;, &quot;d&quot;, &quot;c&quot;, &quot;a&quot;, &quot;z&quot;, &quot;g&quot;])</code> يجب أن ترجع <code>[&quot;a&quot;, &quot;a&quot;, &quot;c&quot;, &quot;d&quot;, &quot;g&quot;, &quot;z&quot;]</code> .'
testString: 'assert(JSON.stringify(alphabeticalOrder(["a", "d", "c", "a", "z", "g"])) === JSON.stringify(["a", "a", "c", "d", "g", "z"]), "<code>alphabeticalOrder(["a", "d", "c", "a", "z", "g"])</code> should return <code>["a", "a", "c", "d", "g", "z"]</code>.");'
- text: '<code>alphabeticalOrder([&quot;x&quot;, &quot;h&quot;, &quot;a&quot;, &quot;m&quot;, &quot;n&quot;, &quot;m&quot;])</code> يجب أن ترجع <code>[&quot;a&quot;, &quot;h&quot;, &quot;m&quot;, &quot;m&quot;, &quot;n&quot;, &quot;x&quot;]</code> .'
testString: 'assert(JSON.stringify(alphabeticalOrder(["x", "h", "a", "m", "n", "m"])) === JSON.stringify(["a", "h", "m", "m", "n", "x"]), "<code>alphabeticalOrder(["x", "h", "a", "m", "n", "m"])</code> should return <code>["a", "h", "m", "m", "n", "x"]</code>.");'
- text: '<code>alphabeticalOrder([&quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;x&quot;, &quot;t&quot;])</code> يجب أن ترجع <code>[&quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;a&quot;, &quot;t&quot;, &quot;x&quot;]</code> .'
testString: 'assert(JSON.stringify(alphabeticalOrder(["a", "a", "a", "a", "x", "t"])) === JSON.stringify(["a", "a", "a", "a", "t", "x"]), "<code>alphabeticalOrder(["a", "a", "a", "a", "x", "t"])</code> should return <code>["a", "a", "a", "a", "t", "x"]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function alphabeticalOrder(arr) {
// Add your code below this line
// Add your code above this line
}
alphabeticalOrder(["a", "d", "c", "a", "z", "g"]);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,61 @@
---
id: 587d7daa367417b2b2512b6b
title: Split a String into an Array Using the split Method
challengeType: 1
videoUrl: ''
localeTitle: تقسيم سلسلة في صفيف باستخدام طريقة الانقسام
---
## Description
<section id="description"> <code>split</code> طريقة الانقسام إلى سلسلة في صفيف من السلاسل. يتطلب الأمر حجة للمُحدد ، والتي يمكن أن تكون حرفًا تستخدم لتجزئة السلسلة أو التعبير العادي. على سبيل المثال ، إذا كان المحدد مساحة ، تحصل على صفيف من الكلمات ، وإذا كان المحدد عبارة عن سلسلة فارغة ، فستحصل على مصفوفة لكل حرف في السلسلة. في ما يلي مثالان يقومان بتقسيم سلسلة واحدة بمسافات ، ثم آخر بالأرقام باستخدام تعبير عادي: <blockquote style=";text-align:right;direction:rtl"> var str = &quot;Hello World&quot;؛ <br> var bySpace = str.split (&quot;&quot;<br> // Sets bySpace to [&quot;Hello&quot;، &quot;World&quot;] <br><br> var otherString = &quot;How9are7you2today&quot; ؛ <br> var byDigits = otherString.split (/ \ d /)؛ <br> // Sets byDigits to [&quot;How&quot;، &quot;are&quot;، &quot;you&quot;، &quot;today&quot;] </blockquote> بما أن الجمل غير قابلة للتغيير ، فإن طريقة <code>split</code> تجعل من السهل العمل معهم. </section>
## Instructions
<section id="instructions"> استخدم طريقة <code>split</code> داخل الدالة <code>splitify</code> لتقسيم <code>str</code> إلى صفيف من الكلمات. يجب أن ترجع الدالة الصفيف. لاحظ أنه لا يتم دائمًا فصل الكلمات عن مسافات ، ويجب ألا يحتوي الصفيف على علامات ترقيم. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن تستخدم التعليمات البرمجية الخاصة بك طريقة <code>split</code> .
testString: 'assert(code.match(/\.split/g), "Your code should use the <code>split</code> method.");'
- text: '<code>splitify(&quot;Hello World,I-am code&quot;)</code> يجب أن تعرض <code>[&quot;Hello&quot;, &quot;World&quot;, &quot;I&quot;, &quot;am&quot;, &quot;code&quot;]</code> .'
testString: 'assert(JSON.stringify(splitify("Hello World,I-am code")) === JSON.stringify(["Hello", "World", "I", "am", "code"]), "<code>splitify("Hello World,I-am code")</code> should return <code>["Hello", "World", "I", "am", "code"]</code>.");'
- text: '<code>splitify(&quot;Earth-is-our home&quot;)</code> يجب أن تعود <code>[&quot;Earth&quot;, &quot;is&quot;, &quot;our&quot;, &quot;home&quot;]</code> .'
testString: 'assert(JSON.stringify(splitify("Earth-is-our home")) === JSON.stringify(["Earth", "is", "our", "home"]), "<code>splitify("Earth-is-our home")</code> should return <code>["Earth", "is", "our", "home"]</code>.");'
- text: '<code>splitify(&quot;This.is.a-sentence&quot;)</code> يجب أن ترجع <code>[&quot;This&quot;, &quot;is&quot;, &quot;a&quot;, &quot;sentence&quot;]</code> .'
testString: 'assert(JSON.stringify(splitify("This.is.a-sentence")) === JSON.stringify(["This", "is", "a", "sentence"]), "<code>splitify("This.is.a-sentence")</code> should return <code>["This", "is", "a", "sentence"]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function splitify(str) {
// Add your code below this line
// Add your code above this line
}
splitify("Hello World,I-am code");
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,94 @@
---
id: 587d7b8e367417b2b2512b5c
title: Understand Functional Programming Terminology
challengeType: 1
videoUrl: ''
localeTitle: فهم البرمجة الوظيفية المصطلحات
---
## Description
<section id="description"> كان فريق لجنة الاتصالات الفيدرالية قد تأرجح المزاج ويريد الآن نوعين من الشاي: الشاي الأخضر والشاي الأسود. حقائق عامة: تقلبات مزاج العميل شائعة جدًا. باستخدام هذه المعلومات ، سنحتاج إلى إعادة النظر في وظيفة <code>getTea</code> من التحدي الأخير للتعامل مع طلبات الشاي المختلفة. يمكننا تعديل <code>getTea</code> لقبول وظيفة كمعلمة لتكون قادرة على تغيير نوع الشاي الذي تقوم بإعداده. وهذا يجعل <code>getTea</code> أكثر مرونة ، ويعطي للمبرمج مزيدًا من التحكم عند تغيير طلبات العميل. لكن أولاً ، دعونا نغطي بعض المصطلحات الفنية: <code>Callbacks</code> هي الوظائف التي يتم تمريرها أو تمريرها إلى وظيفة أخرى لتحديد طلب هذه الوظيفة. ربما تكون قد شاهدتهم مروراً بطرق أخرى ، على سبيل المثال في <code>filter</code> ، تخبر وظيفة معاودة الاتصال JavaScript عن كيفية تصفية مصفوفة. تدعى الدالات التي يمكن تعيينها لمتغير ، يتم تمريرها إلى دالة أخرى ، أو يتم إرجاعها من دالة أخرى تمامًا مثل أي قيمة عادية أخرى ، وظائف <code>first class</code> . في JavaScript ، تعد جميع الوظائف من وظائف <code>first class</code> . تسمى الدالات التي تأخذ دالة كوسيطة ، أو ترجع دالة كقيمة إرجاع ، وظائف <code>higher order</code> . عندما يتم تمرير الوظائف إلى وظيفة أخرى أو يتم إرجاعها من وظيفة أخرى ، فإن تلك الوظائف التي يتم تمريرها أو إعادتها يمكن أن تسمى <code>lambda</code> . </section>
## Instructions
<section id="instructions"> إعداد 27 أكواب من الشاي الأخضر و 13 أكواب من الشاي الأسود وتخزينها في <code>tea4GreenTeamFCC</code> و <code>tea4BlackTeamFCC</code> المتغيرات، على التوالي. لاحظ أن وظيفة <code>getTea</code> قد تم تعديلها بحيث تأخذ الآن وظيفة كالوسيطة الأولى. ملاحظة: يتم توفير البيانات (عدد أكواب الشاي) كوسيطة أخيرة. سنناقش هذا أكثر في الدروس اللاحقة. </section>
## Tests
<section id='tests'>
```yml
tests:
- text: يجب أن <code>tea4GreenTeamFCC</code> المتغير <code>tea4GreenTeamFCC</code> على 27 كوب شاي أخضر للفريق.
testString: 'assert(tea4GreenTeamFCC.length === 27, "The <code>tea4GreenTeamFCC</code> variable should hold 27 cups of green tea for the team.");'
- text: يجب أن يحتفظ المتغير <code>tea4GreenTeamFCC</code> من الشاي الأخضر.
testString: 'assert(tea4GreenTeamFCC[0] === "greenTea", "The <code>tea4GreenTeamFCC</code> variable should hold cups of green tea.");'
- text: يجب أن يحتفظ المتغير <code>tea4BlackTeamFCC</code> 13 كوب من الشاي الأسود.
testString: 'assert(tea4BlackTeamFCC.length === 13, "The <code>tea4BlackTeamFCC</code> variable should hold 13 cups of black tea.");'
- text: يجب أن يحتفظ المتغير <code>tea4BlackTeamFCC</code> الشاي الأسود.
testString: 'assert(tea4BlackTeamFCC[0] === "blackTea", "The <code>tea4BlackTeamFCC</code> variable should hold cups of black tea.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
/**
* A long process to prepare green tea.
* @return {string} A cup of green tea.
**/
const prepareGreenTea = () => 'greenTea';
/**
* A long process to prepare black tea.
* @return {string} A cup of black tea.
**/
const prepareBlackTea = () => 'blackTea';
/**
* Get given number of cups of tea.
* @param {function():string} prepareTea The type of tea preparing function.
* @param {number} numOfCups Number of required cups of tea.
* @return {Array<string>} Given amount of tea cups.
**/
const getTea = (prepareTea, numOfCups) => {
const teaCups = [];
for(let cups = 1; cups <= numOfCups; cups += 1) {
const teaCup = prepareTea();
teaCups.push(teaCup);
}
return teaCups;
};
// Add your code below this line
const tea4GreenTeamFCC = null; // :(
const tea4BlackTeamFCC = null; // :(
// Add your code above this line
console.log(
tea4GreenTeamFCC,
tea4BlackTeamFCC
);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,87 @@
---
id: 587d7b8e367417b2b2512b5d
title: Understand the Hazards of Using Imperative Code
challengeType: 1
videoUrl: ''
localeTitle: فهم مخاطر استخدام الرمز الاحتمالي
---
## Description
<section id="description"> البرمجة الوظيفية هي عادة جيدة. إنه يحافظ على سهولة إدارة التعليمة البرمجية ، ويوفر لك من الأخطاء الخداعية. ولكن قبل أن نصل إلى هناك ، فلننظر إلى مقاربة حتمية للبرمجة لإلقاء الضوء على المواضع التي قد تواجهك فيها. في اللغة الإنجليزية (والعديد من اللغات الأخرى) ، يتم استخدام الفعل الحتمي لإعطاء الأوامر. وبالمثل ، فإن أسلوبًا إلزاميًا في البرمجة هو أسلوب يمنح الكمبيوتر مجموعة من العبارات لتنفيذ مهمة ما. غالبًا ما تؤدي العبارات إلى تغيير حالة البرنامج ، مثل تحديث المتغيرات العامة. المثال الكلاسيكي هو كتابة حلقة <code>for</code> والتي تعطي اتجاهات دقيقة لتكرارها فوق مؤشرات الصفيف. وفي المقابل ، تعد البرمجة الوظيفية شكلاً من أشكال البرمجة التعريفية. تخبر الكمبيوتر بما تريد القيام به عن طريق استدعاء طريقة أو وظيفة. تقدم JavaScript العديد من الطرق المحددة مسبقًا التي تتعامل مع المهام الشائعة ، لذا لا تحتاج إلى كتابة طريقة أداء الكمبيوتر لها. على سبيل المثال، بدلا من استخدام <code>for</code> حلقة المذكورة أعلاه، يمكن استدعاء <code>map</code> الطريقة التي يعالج تفاصيل بالتكرار عبر صفيف. يساعد هذا في تجنب الأخطاء الدلالية ، مثل &quot;Off By One Errors&quot; التي تمت تغطيتها في قسم التصحيح. فكر في السيناريو: أنت تتصفح الويب في متصفحك وتريد تتبع علامات التبويب التي فتحتها. دعونا نحاول هذا النموذج باستخدام بعض التعليمات البرمجية بسيطة وجوه المنحى. يتكون كائن إطار من علامات التبويب ، وعادة ما يكون لديك أكثر من نافذة مفتوحة. يتم الاحتفاظ بعناوين كل موقع مفتوح في كل كائن نافذة في مصفوفة. بعد العمل في المستعرض (فتح علامات تبويب جديدة ، ودمج النوافذ ، وعلامات الإغلاق) ، تريد طباعة علامات التبويب التي لا تزال مفتوحة. تتم إزالة علامات التبويب المغلقة من الصفيف وتضاف علامات التبويب الجديدة (للبساطة) إلى نهايتها. يعرض محرر التعليمة البرمجية تطبيقًا لهذه الوظيفة بوظائف <code>tabOpen()</code> و <code>tabClose()</code> و <code>join()</code> . تعتبر <code>tabs</code> الصفائف جزءًا من كائن الإطار الذي يخزن اسم الصفحات المفتوحة. <h4 style=";text-align:right;direction:rtl"> تعليمات </h4><h4 style=";text-align:right;direction:rtl"> قم بتشغيل الكود في المحرر. إنها تستخدم طريقة لها آثار جانبية في البرنامج ، مما يتسبب في إخراج غير صحيح. يجب أن تكون القائمة النهائية لعلامات التبويب المفتوحة <code>[&#39;FB&#39;, &#39;Gitter&#39;, &#39;Reddit&#39;, &#39;Twitter&#39;, &#39;Medium&#39;, &#39;new tab&#39;, &#39;Netflix&#39;, &#39;YouTube&#39;, &#39;Vine&#39;, &#39;GMail&#39;, &#39;Work mail&#39;, &#39;Docs&#39;, &#39;freeCodeCamp&#39;, &#39;new tab&#39;]</code> ولكن الإخراج سيكون مختلفًا بعض الشيء. اعمل من خلال الشفرة واكتشف ما إذا كان يمكنك معرفة المشكلة ، ثم تقدم إلى التحدي التالي لمعرفة المزيد. </h4></section>
## Instructions
<section id="instructions">
</section>
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(true, "Move ahead to understand the error.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// tabs is an array of titles of each site open within the window
var Window = function(tabs) {
this.tabs = tabs; // we keep a record of the array inside the object
};
// When you join two windows into one window
Window.prototype.join = function (otherWindow) {
this.tabs = this.tabs.concat(otherWindow.tabs);
return this;
};
// When you open a new tab at the end
Window.prototype.tabOpen = function (tab) {
this.tabs.push('new tab'); // let's open a new tab for now
return this;
};
// When you close a tab
Window.prototype.tabClose = function (index) {
var tabsBeforeIndex = this.tabs.splice(0, index); // get the tabs before the tab
var tabsAfterIndex = this.tabs.splice(index); // get the tabs after the tab
this.tabs = tabsBeforeIndex.concat(tabsAfterIndex); // join them together
return this;
};
// Let's create three browser windows
var workWindow = new Window(['GMail', 'Inbox', 'Work mail', 'Docs', 'freeCodeCamp']); // Your mailbox, drive, and other work sites
var socialWindow = new Window(['FB', 'Gitter', 'Reddit', 'Twitter', 'Medium']); // Social sites
var videoWindow = new Window(['Netflix', 'YouTube', 'Vimeo', 'Vine']); // Entertainment sites
// Now perform the tab opening, closing, and other operations
var finalTabs = socialWindow
.tabOpen() // Open a new tab for cat memes
.join(videoWindow.tabClose(2)) // Close third tab in video window, and join
.join(workWindow.tabClose(1).tabOpen());
alert(finalTabs.tabs);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,61 @@
---
id: 587d7dab367417b2b2512b6e
title: Use the every Method to Check that Every Element in an Array Meets a Criteria
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(code.match(/\.every/g), "Your code should use the <code>every</code> method.");'
- text: ''
testString: 'assert(!checkPositive([1, 2, 3, -4, 5]), "<code>checkPositive([1, 2, 3, -4, 5])</code> should return <code>false</code>.");'
- text: ''
testString: 'assert(checkPositive([1, 2, 3, 4, 5]), "<code>checkPositive([1, 2, 3, 4, 5])</code> should return <code>true</code>.");'
- text: ''
testString: 'assert(!checkPositive([1, -2, 3, -4, 5]), "<code>checkPositive([1, -2, 3, -4, 5])</code> should return <code>false</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function checkPositive(arr) {
// Add your code below this line
// Add your code above this line
}
checkPositive([1, 2, 3, -4, 5]);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,175 @@
---
id: 587d7b8f367417b2b2512b63
title: Use the filter Method to Extract Data from an Array
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron", "The <code>watchList</code> variable should not change.");'
- text: ''
testString: 'assert(code.match(/\.filter/g), "Your code should use the <code>filter</code> method.");'
- text: ''
testString: 'assert(!code.match(/for\s*?\(.+?\)/g), "Your code should not use a <code>for</code> loop.");'
- text: ''
testString: 'assert.deepEqual(filteredList, [{"title": "Inception","rating": "8.8"},{"title": "Interstellar","rating": "8.6"},{"title": "The Dark Knight","rating": "9.0"},{"title": "Batman Begins","rating": "8.3"}], "<code>filteredList</code> should equal <code>[{"title": "Inception","rating": "8.8"},{"title": "Interstellar","rating": "8.6"},{"title": "The Dark Knight","rating": "9.0"},{"title": "Batman Begins","rating": "8.3"}]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// the global variable
var watchList = [
{
"Title": "Inception",
"Year": "2010",
"Rated": "PG-13",
"Released": "16 Jul 2010",
"Runtime": "148 min",
"Genre": "Action, Adventure, Crime",
"Director": "Christopher Nolan",
"Writer": "Christopher Nolan",
"Actors": "Leonardo DiCaprio, Joseph Gordon-Levitt, Ellen Page, Tom Hardy",
"Plot": "A thief, who steals corporate secrets through use of dream-sharing technology, is given the inverse task of planting an idea into the mind of a CEO.",
"Language": "English, Japanese, French",
"Country": "USA, UK",
"Awards": "Won 4 Oscars. Another 143 wins & 198 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1_SX300.jpg",
"Metascore": "74",
"imdbRating": "8.8",
"imdbVotes": "1,446,708",
"imdbID": "tt1375666",
"Type": "movie",
"Response": "True"
},
{
"Title": "Interstellar",
"Year": "2014",
"Rated": "PG-13",
"Released": "07 Nov 2014",
"Runtime": "169 min",
"Genre": "Adventure, Drama, Sci-Fi",
"Director": "Christopher Nolan",
"Writer": "Jonathan Nolan, Christopher Nolan",
"Actors": "Ellen Burstyn, Matthew McConaughey, Mackenzie Foy, John Lithgow",
"Plot": "A team of explorers travel through a wormhole in space in an attempt to ensure humanity's survival.",
"Language": "English",
"Country": "USA, UK",
"Awards": "Won 1 Oscar. Another 39 wins & 132 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMjIxNTU4MzY4MF5BMl5BanBnXkFtZTgwMzM4ODI3MjE@._V1_SX300.jpg",
"Metascore": "74",
"imdbRating": "8.6",
"imdbVotes": "910,366",
"imdbID": "tt0816692",
"Type": "movie",
"Response": "True"
},
{
"Title": "The Dark Knight",
"Year": "2008",
"Rated": "PG-13",
"Released": "18 Jul 2008",
"Runtime": "152 min",
"Genre": "Action, Adventure, Crime",
"Director": "Christopher Nolan",
"Writer": "Jonathan Nolan (screenplay), Christopher Nolan (screenplay), Christopher Nolan (story), David S. Goyer (story), Bob Kane (characters)",
"Actors": "Christian Bale, Heath Ledger, Aaron Eckhart, Michael Caine",
"Plot": "When the menace known as the Joker wreaks havoc and chaos on the people of Gotham, the caped crusader must come to terms with one of the greatest psychological tests of his ability to fight injustice.",
"Language": "English, Mandarin",
"Country": "USA, UK",
"Awards": "Won 2 Oscars. Another 146 wins & 142 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMTMxNTMwODM0NF5BMl5BanBnXkFtZTcwODAyMTk2Mw@@._V1_SX300.jpg",
"Metascore": "82",
"imdbRating": "9.0",
"imdbVotes": "1,652,832",
"imdbID": "tt0468569",
"Type": "movie",
"Response": "True"
},
{
"Title": "Batman Begins",
"Year": "2005",
"Rated": "PG-13",
"Released": "15 Jun 2005",
"Runtime": "140 min",
"Genre": "Action, Adventure",
"Director": "Christopher Nolan",
"Writer": "Bob Kane (characters), David S. Goyer (story), Christopher Nolan (screenplay), David S. Goyer (screenplay)",
"Actors": "Christian Bale, Michael Caine, Liam Neeson, Katie Holmes",
"Plot": "After training with his mentor, Batman begins his fight to free crime-ridden Gotham City from the corruption that Scarecrow and the League of Shadows have cast upon it.",
"Language": "English, Urdu, Mandarin",
"Country": "USA, UK",
"Awards": "Nominated for 1 Oscar. Another 15 wins & 66 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BNTM3OTc0MzM2OV5BMl5BanBnXkFtZTYwNzUwMTI3._V1_SX300.jpg",
"Metascore": "70",
"imdbRating": "8.3",
"imdbVotes": "972,584",
"imdbID": "tt0372784",
"Type": "movie",
"Response": "True"
},
{
"Title": "Avatar",
"Year": "2009",
"Rated": "PG-13",
"Released": "18 Dec 2009",
"Runtime": "162 min",
"Genre": "Action, Adventure, Fantasy",
"Director": "James Cameron",
"Writer": "James Cameron",
"Actors": "Sam Worthington, Zoe Saldana, Sigourney Weaver, Stephen Lang",
"Plot": "A paraplegic marine dispatched to the moon Pandora on a unique mission becomes torn between following his orders and protecting the world he feels is his home.",
"Language": "English, Spanish",
"Country": "USA, UK",
"Awards": "Won 3 Oscars. Another 80 wins & 121 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMTYwOTEwNjAzMl5BMl5BanBnXkFtZTcwODc5MTUwMw@@._V1_SX300.jpg",
"Metascore": "83",
"imdbRating": "7.9",
"imdbVotes": "876,575",
"imdbID": "tt0499549",
"Type": "movie",
"Response": "True"
}
];
// Add your code below this line
var filteredList;
// Add your code above this line
console.log(filteredList);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,178 @@
---
id: 587d7b8f367417b2b2512b61
title: Use the map Method to Extract Data from an Array
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron", "The <code>watchList</code> variable should not change.");'
- text: ''
testString: 'assert(!code.match(/for\s*?\(.+?\)/g), "Your code should not use a <code>for</code> loop.");'
- text: ''
testString: 'assert(code.match(/\.map/g), "Your code should use the <code>map</code> method.");'
- text: ''
testString: 'assert(JSON.stringify(rating) === JSON.stringify([{"title":"Inception","rating":"8.8"},{"title":"Interstellar","rating":"8.6"},{"title":"The Dark Knight","rating":"9.0"},{"title":"Batman Begins","rating":"8.3"},{"title":"Avatar","rating":"7.9"}]), "<code>rating</code> should equal <code>[{"title":"Inception","rating":"8.8"},{"title":"Interstellar","rating":"8.6"},{"title":"The Dark Knight","rating":"9.0"},{"title":"Batman Begins","rating":"8.3"},{"title":"Avatar","rating":"7.9"}]</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// the global variable
var watchList = [
{
"Title": "Inception",
"Year": "2010",
"Rated": "PG-13",
"Released": "16 Jul 2010",
"Runtime": "148 min",
"Genre": "Action, Adventure, Crime",
"Director": "Christopher Nolan",
"Writer": "Christopher Nolan",
"Actors": "Leonardo DiCaprio, Joseph Gordon-Levitt, Ellen Page, Tom Hardy",
"Plot": "A thief, who steals corporate secrets through use of dream-sharing technology, is given the inverse task of planting an idea into the mind of a CEO.",
"Language": "English, Japanese, French",
"Country": "USA, UK",
"Awards": "Won 4 Oscars. Another 143 wins & 198 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1_SX300.jpg",
"Metascore": "74",
"imdbRating": "8.8",
"imdbVotes": "1,446,708",
"imdbID": "tt1375666",
"Type": "movie",
"Response": "True"
},
{
"Title": "Interstellar",
"Year": "2014",
"Rated": "PG-13",
"Released": "07 Nov 2014",
"Runtime": "169 min",
"Genre": "Adventure, Drama, Sci-Fi",
"Director": "Christopher Nolan",
"Writer": "Jonathan Nolan, Christopher Nolan",
"Actors": "Ellen Burstyn, Matthew McConaughey, Mackenzie Foy, John Lithgow",
"Plot": "A team of explorers travel through a wormhole in space in an attempt to ensure humanity's survival.",
"Language": "English",
"Country": "USA, UK",
"Awards": "Won 1 Oscar. Another 39 wins & 132 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMjIxNTU4MzY4MF5BMl5BanBnXkFtZTgwMzM4ODI3MjE@._V1_SX300.jpg",
"Metascore": "74",
"imdbRating": "8.6",
"imdbVotes": "910,366",
"imdbID": "tt0816692",
"Type": "movie",
"Response": "True"
},
{
"Title": "The Dark Knight",
"Year": "2008",
"Rated": "PG-13",
"Released": "18 Jul 2008",
"Runtime": "152 min",
"Genre": "Action, Adventure, Crime",
"Director": "Christopher Nolan",
"Writer": "Jonathan Nolan (screenplay), Christopher Nolan (screenplay), Christopher Nolan (story), David S. Goyer (story), Bob Kane (characters)",
"Actors": "Christian Bale, Heath Ledger, Aaron Eckhart, Michael Caine",
"Plot": "When the menace known as the Joker wreaks havoc and chaos on the people of Gotham, the caped crusader must come to terms with one of the greatest psychological tests of his ability to fight injustice.",
"Language": "English, Mandarin",
"Country": "USA, UK",
"Awards": "Won 2 Oscars. Another 146 wins & 142 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMTMxNTMwODM0NF5BMl5BanBnXkFtZTcwODAyMTk2Mw@@._V1_SX300.jpg",
"Metascore": "82",
"imdbRating": "9.0",
"imdbVotes": "1,652,832",
"imdbID": "tt0468569",
"Type": "movie",
"Response": "True"
},
{
"Title": "Batman Begins",
"Year": "2005",
"Rated": "PG-13",
"Released": "15 Jun 2005",
"Runtime": "140 min",
"Genre": "Action, Adventure",
"Director": "Christopher Nolan",
"Writer": "Bob Kane (characters), David S. Goyer (story), Christopher Nolan (screenplay), David S. Goyer (screenplay)",
"Actors": "Christian Bale, Michael Caine, Liam Neeson, Katie Holmes",
"Plot": "After training with his mentor, Batman begins his fight to free crime-ridden Gotham City from the corruption that Scarecrow and the League of Shadows have cast upon it.",
"Language": "English, Urdu, Mandarin",
"Country": "USA, UK",
"Awards": "Nominated for 1 Oscar. Another 15 wins & 66 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BNTM3OTc0MzM2OV5BMl5BanBnXkFtZTYwNzUwMTI3._V1_SX300.jpg",
"Metascore": "70",
"imdbRating": "8.3",
"imdbVotes": "972,584",
"imdbID": "tt0372784",
"Type": "movie",
"Response": "True"
},
{
"Title": "Avatar",
"Year": "2009",
"Rated": "PG-13",
"Released": "18 Dec 2009",
"Runtime": "162 min",
"Genre": "Action, Adventure, Fantasy",
"Director": "James Cameron",
"Writer": "James Cameron",
"Actors": "Sam Worthington, Zoe Saldana, Sigourney Weaver, Stephen Lang",
"Plot": "A paraplegic marine dispatched to the moon Pandora on a unique mission becomes torn between following his orders and protecting the world he feels is his home.",
"Language": "English, Spanish",
"Country": "USA, UK",
"Awards": "Won 3 Oscars. Another 80 wins & 121 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMTYwOTEwNjAzMl5BMl5BanBnXkFtZTcwODc5MTUwMw@@._V1_SX300.jpg",
"Metascore": "83",
"imdbRating": "7.9",
"imdbVotes": "876,575",
"imdbID": "tt0499549",
"Type": "movie",
"Response": "True"
}
];
// Add your code below this line
var rating = [];
for(var i=0; i < watchList.length; i++){
rating.push({title: watchList[i]["Title"], rating: watchList[i]["imdbRating"]});
}
// Add your code above this line
console.log(rating);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,175 @@
---
id: 587d7da9367417b2b2512b68
title: Use the reduce Method to Analyze Data
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(watchList[0].Title === "Inception" && watchList[4].Director == "James Cameron", "The <code>watchList</code> variable should not change.");'
- text: ''
testString: 'assert(code.match(/\.reduce/g), "Your code should use the <code>reduce</code> method.");'
- text: ''
testString: 'assert(averageRating == 8.675, "The <code>averageRating</code> should equal 8.675.");'
- text: ''
testString: 'assert(!code.match(/for\s*?\(.*\)/g), "Your code should not use a <code>for</code> loop.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
// the global variable
var watchList = [
{
"Title": "Inception",
"Year": "2010",
"Rated": "PG-13",
"Released": "16 Jul 2010",
"Runtime": "148 min",
"Genre": "Action, Adventure, Crime",
"Director": "Christopher Nolan",
"Writer": "Christopher Nolan",
"Actors": "Leonardo DiCaprio, Joseph Gordon-Levitt, Ellen Page, Tom Hardy",
"Plot": "A thief, who steals corporate secrets through use of dream-sharing technology, is given the inverse task of planting an idea into the mind of a CEO.",
"Language": "English, Japanese, French",
"Country": "USA, UK",
"Awards": "Won 4 Oscars. Another 143 wins & 198 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1_SX300.jpg",
"Metascore": "74",
"imdbRating": "8.8",
"imdbVotes": "1,446,708",
"imdbID": "tt1375666",
"Type": "movie",
"Response": "True"
},
{
"Title": "Interstellar",
"Year": "2014",
"Rated": "PG-13",
"Released": "07 Nov 2014",
"Runtime": "169 min",
"Genre": "Adventure, Drama, Sci-Fi",
"Director": "Christopher Nolan",
"Writer": "Jonathan Nolan, Christopher Nolan",
"Actors": "Ellen Burstyn, Matthew McConaughey, Mackenzie Foy, John Lithgow",
"Plot": "A team of explorers travel through a wormhole in space in an attempt to ensure humanity's survival.",
"Language": "English",
"Country": "USA, UK",
"Awards": "Won 1 Oscar. Another 39 wins & 132 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMjIxNTU4MzY4MF5BMl5BanBnXkFtZTgwMzM4ODI3MjE@._V1_SX300.jpg",
"Metascore": "74",
"imdbRating": "8.6",
"imdbVotes": "910,366",
"imdbID": "tt0816692",
"Type": "movie",
"Response": "True"
},
{
"Title": "The Dark Knight",
"Year": "2008",
"Rated": "PG-13",
"Released": "18 Jul 2008",
"Runtime": "152 min",
"Genre": "Action, Adventure, Crime",
"Director": "Christopher Nolan",
"Writer": "Jonathan Nolan (screenplay), Christopher Nolan (screenplay), Christopher Nolan (story), David S. Goyer (story), Bob Kane (characters)",
"Actors": "Christian Bale, Heath Ledger, Aaron Eckhart, Michael Caine",
"Plot": "When the menace known as the Joker wreaks havoc and chaos on the people of Gotham, the caped crusader must come to terms with one of the greatest psychological tests of his ability to fight injustice.",
"Language": "English, Mandarin",
"Country": "USA, UK",
"Awards": "Won 2 Oscars. Another 146 wins & 142 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMTMxNTMwODM0NF5BMl5BanBnXkFtZTcwODAyMTk2Mw@@._V1_SX300.jpg",
"Metascore": "82",
"imdbRating": "9.0",
"imdbVotes": "1,652,832",
"imdbID": "tt0468569",
"Type": "movie",
"Response": "True"
},
{
"Title": "Batman Begins",
"Year": "2005",
"Rated": "PG-13",
"Released": "15 Jun 2005",
"Runtime": "140 min",
"Genre": "Action, Adventure",
"Director": "Christopher Nolan",
"Writer": "Bob Kane (characters), David S. Goyer (story), Christopher Nolan (screenplay), David S. Goyer (screenplay)",
"Actors": "Christian Bale, Michael Caine, Liam Neeson, Katie Holmes",
"Plot": "After training with his mentor, Batman begins his fight to free crime-ridden Gotham City from the corruption that Scarecrow and the League of Shadows have cast upon it.",
"Language": "English, Urdu, Mandarin",
"Country": "USA, UK",
"Awards": "Nominated for 1 Oscar. Another 15 wins & 66 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BNTM3OTc0MzM2OV5BMl5BanBnXkFtZTYwNzUwMTI3._V1_SX300.jpg",
"Metascore": "70",
"imdbRating": "8.3",
"imdbVotes": "972,584",
"imdbID": "tt0372784",
"Type": "movie",
"Response": "True"
},
{
"Title": "Avatar",
"Year": "2009",
"Rated": "PG-13",
"Released": "18 Dec 2009",
"Runtime": "162 min",
"Genre": "Action, Adventure, Fantasy",
"Director": "James Cameron",
"Writer": "James Cameron",
"Actors": "Sam Worthington, Zoe Saldana, Sigourney Weaver, Stephen Lang",
"Plot": "A paraplegic marine dispatched to the moon Pandora on a unique mission becomes torn between following his orders and protecting the world he feels is his home.",
"Language": "English, Spanish",
"Country": "USA, UK",
"Awards": "Won 3 Oscars. Another 80 wins & 121 nominations.",
"Poster": "http://ia.media-imdb.com/images/M/MV5BMTYwOTEwNjAzMl5BMl5BanBnXkFtZTcwODc5MTUwMw@@._V1_SX300.jpg",
"Metascore": "83",
"imdbRating": "7.9",
"imdbVotes": "876,575",
"imdbID": "tt0499549",
"Type": "movie",
"Response": "True"
}
];
// Add your code below this line
var averageRating;
// Add your code above this line
console.log(averageRating);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>

View File

@ -0,0 +1,61 @@
---
id: 587d7dab367417b2b2512b6f
title: Use the some Method to Check that Any Elements in an Array Meet a Criteria
challengeType: 1
videoUrl: ''
localeTitle: ''
---
## Description
undefined
## Instructions
undefined
## Tests
<section id='tests'>
```yml
tests:
- text: ''
testString: 'assert(code.match(/\.some/g), "Your code should use the <code>some</code> method.");'
- text: ''
testString: 'assert(checkPositive([1, 2, 3, -4, 5]), "<code>checkPositive([1, 2, 3, -4, 5])</code> should return <code>true</code>.");'
- text: ''
testString: 'assert(checkPositive([1, 2, 3, 4, 5]), "<code>checkPositive([1, 2, 3, 4, 5])</code> should return <code>true</code>.");'
- text: ''
testString: 'assert(!checkPositive([-1, -2, -3, -4, -5]), "<code>checkPositive([-1, -2, -3, -4, -5])</code> should return <code>false</code>.");'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
```js
function checkPositive(arr) {
// Add your code below this line
// Add your code above this line
}
checkPositive([1, 2, 3, -4, 5]);
```
</div>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>