fix(guide): simplify directory structure

This commit is contained in:
Mrugesh Mohapatra
2018-10-16 21:26:13 +05:30
parent f989c28c52
commit da0df12ab7
35752 changed files with 0 additions and 317652 deletions

View File

@@ -0,0 +1,27 @@
---
title: Add Elements to the End of an Array Using concat Instead of push
localeTitle: إضافة عناصر إلى نهاية صفيف باستخدام concat بدلاً من الضغط
---
## إضافة عناصر إلى نهاية صفيف باستخدام concat بدلاً من الضغط
عندما تضيف طريقة `push` عنصرًا جديدًا إلى نهاية الصفيف الأصلي ، تنشئ طريقة `concat` صفيفًا جديدًا يحتوي على العناصر من الصفيف الأصلي والعنصر الجديد. الصفيف الأصلي لا يزال هو نفسه عند استخدام `concat` .
#### روابط ذات صلة:
* [Array.prototype.concat ()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat)
## حل
`function nonMutatingPush(original, newItem) {
// Add your code below this line
return original.concat(newItem);
// Add your code above this line
}
var first = [1, 2, 3];
var second = [4, 5];
nonMutatingPush(first, second);
`

View File

@@ -0,0 +1,36 @@
---
title: Apply Functional Programming to Convert Strings to URL Slugs
localeTitle: تطبيق برمجة وظيفية لتحويل السلاسل إلى Slug URL
---
## تطبيق برمجة وظيفية لتحويل السلاسل إلى Slug URL
### حل
`// the global variable
var globalTitle = "Winter Is Coming";
// Add your code below this line
function urlSlug(title) {
return title.split(/\W/).filter((obj)=>{
return obj !=='';
}).join('-').toLowerCase();
}
// Add your code above this line
var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"
`
### حل بديل
`// the global variable
var globalTitle = "Winter Is Coming";
// Add your code below this line
function urlSlug(title) {
return title.toLowerCase().trim().split(/\s+/).join('-');
}
// Add your code above this line
var winterComing = urlSlug(globalTitle); // Should be "winter-is-coming"
`

View File

@@ -0,0 +1,29 @@
---
title: Avoid Mutations and Side Effects Using Functional Programming
localeTitle: تجنب الطفرات والآثار الجانبية باستخدام البرمجة الوظيفية
---
## تجنب الطفرات والآثار الجانبية باستخدام البرمجة الوظيفية
### شرح المشكلة
ملء رمز لوظيفة `incrementer` بحيث تقوم بإرجاع قيمة المتغير العالمي `fixedValue` بنسبة واحد. `fixedValue` يجب ألا يتغير ، بغض النظر عن عدد المرات التي يطلق عليها الدالة `incrememter` .
### تلميح 1
يؤدي استخدام عامل الزيادة ( `++` ) على `fixedValue` إلى `fixedValue` ، مما يعني أنها لن تعد تشير إلى نفس القيمة التي تم تعيينها لها.
### حل:
`// the global variable
var fixedValue = 4;
function incrementer () {
// Add your code below this line
return fixedValue + 1;
// Add your code above this line
}
var newValue = incrementer(); // Should equal 5
console.log(fixedValue); // Should print 4
`

View File

@@ -0,0 +1,33 @@
---
title: Combine an Array into a String Using the join Method
localeTitle: دمج صفيف في سلسلة باستخدام طريقة الانضمام
---
## ضم مجموعة في سلسلة باستخدام أسلوب الانضمام
### شرح المشكلة
استخدم طريقة `join` (من بين آخرين) داخل الدالة `sentensify` لإنشاء جملة من الكلمات في `str` السلسلة. يجب على الدالة إرجاع سلسلة. على سبيل المثال ، سيتم تحويل "I-like-Star-Wars" إلى "I like Star Wars". لهذا التحدي ، لا تستخدم طريقة `replace` .
#### روابط ذات صلة:
* [Array.prototype.join ()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join)
* [String.prototype.split ()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split)
* [التعبيرات العادية](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions)
### Hint1
قد تحتاج إلى تحويل السلسلة إلى صفيف أولاً.
### Hint2
قد تحتاج إلى استخدام تعبير عادي لتقسيم السلسلة.
### حل:
`function sentensify(str) {
// Add your code below this line
return str.split(/\W/).join(' ');
// Add your code above this line
}
sentensify("May-the-force-be-with-you");
`

View File

@@ -0,0 +1,22 @@
---
title: Combine Two Arrays Using the concat Method
localeTitle: الجمع بين اثنين من المصفوفات باستخدام طريقة concat
---
## الجمع بين اثنين من المصفوفات باستخدام طريقة concat
* يتم استخدام الأسلوب concat لربط صفيفين أو أكثر أو سلاسل.
* هذه الطريقة لا تحوِّل الصفائف الموجودة ، ولكنها تعيد صفيفًا جديدًا.
## حل
`function nonMutatingConcat(original, attach) {
// Add your code below this line
return original.concat(attach);
// Add your code above this line
}
var first = [1, 2, 3];
var second = [4, 5];
nonMutatingConcat(first, second);
`

View File

@@ -0,0 +1,33 @@
---
title: Implement map on a Prototype
localeTitle: تنفيذ الخريطة على نموذج أولي
---
## تنفيذ الخريطة على نموذج أولي
لحل هذا التحدي باستخدام الكلمة الرئيسية هذا هو المفتاح.
سيتيح لنا الوصول إلى الكائن الذي نطلق عليه myMap.
ومن هناك ، يمكننا استخدام forEach أو for loop لإضافة عناصر إلى مصفوفة فارغة تم تعريفها بالفعل ، حيث نقوم بتعديل كل عنصر باستخدام طريقة رد الاتصال المحددة.
`// the global Array
var s = [23, 65, 98, 5];
Array.prototype.myMap = function(callback){
var newArray = [];
// Add your code below this line
this.forEach(a => newArray.push(callback(a)));
// Add your code above this line
return newArray;
};
var new_s = s.myMap(function(item){
return item * 2;
});
`
### روابط مفيدة
[هذه. Javascript MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/this)
[هذه. جافا سكريبت W3Schools](https://www.w3schools.com/js/js_this.asp)

View File

@@ -0,0 +1,42 @@
---
title: Implement the filter Method on a Prototype
localeTitle: تنفيذ مرشح طريقة على النموذج
---
## تنفيذ مرشح طريقة على النموذج
`// the global Array
var s = [23, 65, 98, 5];
Array.prototype.myFilter = function(callback){
var newArray = [];
// Add your code below this line
this.forEach(function(x) {
if (callback(x) == true) {
newArray.push(x);
}
})
// Add your code above this line
return newArray;
};
`
## حل آخر باستخدام looop!
`Array.prototype.myFilter = function(callback){
var newArray = [];
// Add your code below this line
for (let i=0; i<this.length;i++){
if(callback(this[i])=== true ){
newArray.push(this[i]);
}
}
// Add your code above this line
return newArray;
};
var new_s = s.myFilter(function(item){
return item % 2 === 1;
});
`

View File

@@ -0,0 +1,11 @@
---
title: Functional Programming
localeTitle: برمجة وظيفية
---
## برمجة وظيفية
هذا هو كعب. [ساعد مجتمعنا على توسيعه](https://github.com/freecodecamp/guides/tree/master/src/pages/mathematics/quadratic-equations/index.md) .
[سيساعدك دليل النمط السريع هذا على ضمان قبول طلب السحب](https://github.com/freecodecamp/guides/blob/master/README.md) .
#### معلومات اكثر:

View File

@@ -0,0 +1,19 @@
---
title: Introduction to Currying and Partial Application
localeTitle: مقدمة في التجلي والتطبيق الجزئي
---
## مقدمة في التجلي والتطبيق الجزئي
### حل
`function add(x) {
// Add your code below this line
return function(y) {
return function(z) {
return x + y + z;
}
}
// Add your code above this line
}
add(10)(20)(30);
`

View File

@@ -0,0 +1,46 @@
---
title: Learn About Functional Programming
localeTitle: تعرف على برمجة وظيفية
---
## تعرف على برمجة وظيفية
تحتوي الدالة على إدخال أو معلمة `const myFunc = (input) => { ...code to execute... }` . في هذه الحالة ، الإدخال هو عدد أكواب الشاي المراد إنشاؤها.
### طريقة
يجب تغيير سطر واحد فقط من رمز لتمرير هذا challenege. يجب استدعاء الدالة `getTea()` وتخزينها في متغير `tea4TeamFCC` . تأكد من قراءة وظيفة `getTea()` وفهم ما يفعله بالضبط. تأخذ الدالة في متغير واحد - `numOfCups` . يتم `teaCups[]` صفيف `teaCups[]` لأول مرة ويتم إعداد حلقة for up لأعداد عدد الكؤوس التي تم تمريرها إلى الدالة. ثم يتم دفع كوب جديد من الشاي إلى الصفيف من خلال كل تكرار للحلقة.
وبالتالي نتج عنه صفيف مليء `getTea()` الشاي التي تم تمريرها في الأصل إلى وظيفة `getTea()` .
### حل
`/**
* 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 = getTea(40); // :(
// Add your code above this line
console.log(tea4TeamFCC);
`

View File

@@ -0,0 +1,31 @@
---
title: Pass Arguments to Avoid External Dependence in a Function
localeTitle: تمرير الحجج لتجنب الاعتماد الخارجي في وظيفة
---
## تمرير الحجج لتجنب الاعتماد الخارجي في وظيفة
## تلميح: 1
حاول تمرير الوسيطة للعمل وإرجاع قيمة زيادة هذه الوسيطة.
**الحل في المستقبل!**
## الحل الأساسي للكود:
`// the global variable
var fixedValue = 4;
// Add your code below this line
function incrementer (value) {
return value + 1;
// Add your code above this line
}
var newValue = incrementer(fixedValue); // Should equal 5
console.log(fixedValue); // Should print 4
`
### طريقة
سيوفر هذا الرمز نفس النتيجة `fixedValue` الأخير ، فقط هذه المرة `fixedValue` قيمة `fixedValue` إلى الدالة كمعلمة.

View File

@@ -0,0 +1,43 @@
---
title: Refactor Global Variables Out of Functions
localeTitle: المتغيرات العالمية ريفاكتور من الوظائف
---
## المتغيرات العالمية ريفاكتور من الوظائف
* إذا كنت تواجه مشكلة في تغيير bookList ، فحاول استخدام نسخة من الصفيف في وظائفك.
* إليك بعض المعلومات الإضافية حول \[كيفية معالجة معاملات الدالة JavaScript\] (https://codeburst.io/javascript-passing-by-value-vs- reference-explain-in-plain-english-8d00fd06a47c).
## ![:beginner:](https://forum.freecodecamp.com/images/emoji/emoji_one/beginner.png?v=3 ":مبتدئ:") الحل الأساسي للكود:
## الحل 1
`function add (arr, bookName) {
let newArr = [...arr]; // Copy the bookList array to a new array.
newArr.push(bookName); // Add bookName parameter to the end of the new array.
return newArr; // Return the new array.
}
function remove (arr, bookName) {
let newArr = [...arr]; // Copy the bookList array to a new array.
if (newArr.indexOf(bookName) >= 0) { // Check whether the bookName parameter is in new array.
/.
newArr.splice(newArr.indexOf(bookName), 1); // Remove the given paramater from the new array.
return newArr; // Return the new array.
}
}
`
## الحل 2
`function add (list,bookName) {
return [...list, bookName];
}
function remove (list,bookName) {
if (list.indexOf(bookName) >= 0) {
return list.filter((item) => item !== bookName);
}
}
`

View File

@@ -0,0 +1,22 @@
---
title: Remove Elements from an Array Using slice Instead of splice
localeTitle: إزالة عناصر من صفيف باستخدام شريحة بدلاً من لصق
---
## إزالة عناصر من صفيف باستخدام شريحة بدلاً من لصق
* الفرق بين لصق وطريقة شريحة هو أن طريقة شريحة لا تحور الصفيف الأصلي ، ولكن إرجاع واحدة جديدة.
* تأخذ طريقة الشريحة اثنين من الوسيطتين لبدء المؤشرات وإنهاء الشريحة (النهاية غير شاملة).
* إذا كنت لا تريد تحوير الصفيف الأصلي ، يمكنك استخدام طريقة الشريحة.
## حل
`function nonMutatingSplice(cities) {
// Add your code below this line
return cities.slice(0, 3);
// Add your code above this line
}
var inputCities = ["Chicago", "Delhi", "Islamabad", "London", "Berlin"];
nonMutatingSplice(inputCities);
`

View File

@@ -0,0 +1,22 @@
---
title: Return a Sorted Array Without Changing the Original Array
localeTitle: إرجاع صفيف Sorted دون تغيير في صفيف الأصلي
---
## إرجاع صفيف Sorted دون تغيير في صفيف الأصلي
### طريقة
أولاً تجميع الصفيف المتخذة كمعلمة إلى صفيف فارغ جديد. ثم استخدم الأسلوب `sort()` كما هو موضح في التحدي الأخير وقم بإنشاء دالة لفرز الصفيف الجديد بترتيب تصاعدي.
### حل
`var globalArray = [5, 6, 3, 2, 9];
function nonMutatingSort(arr) {
// Add your code below this line
return [].concat(arr).sort(function(a, b) {
return a - b;
});
// Add your code above this line
}
nonMutatingSort(globalArray);
`

View File

@@ -0,0 +1,32 @@
---
title: Return Part of an Array Using the slice Method
localeTitle: عودة جزء من صفيف باستخدام طريقة شريحة
---
## عودة جزء من صفيف باستخدام طريقة شريحة
### شرح المشكلة
استخدم طريقة الشريحة في وظيفة sliceArray لإرجاع جزء من صفيف الرسوم المتحركة مع الأخذ في الاعتبار مؤشرات startSlice و endSlice المقدمة. يجب على الدالة إرجاع صفيف.
### طريقة
يمكن كتابة الدالة ببساطة عن طريق كتابة سطر واحد من التعليمات البرمجية - عبارة return. تمامًا كما في المثال المعطى ، قم `beginSlice` المصفوفة التي تأخذها الدالة كمعلمة باستخدام معلمات `beginSlice` و `endSlice` كمعلمات `endSlice` `slice()` . تذكر بنية طريقة `slice()` :
`var arr = ["Cat", "Dog", "Tiger", "Zebra", "Ant"];
arr.slice([index-to-begin-slice] , [index-to-end-slice]);
`
### حل
`function sliceArray(anim, beginSlice, endSlice) {
// Add your code below this line
return anim.slice(beginSlice, endSlice);
// Add your code above this line
}
var inputAnim = ["Cat", "Dog", "Tiger", "Zebra", "Ant"];
sliceArray(inputAnim, 1, 3);
`
#### روابط ذات صلة:
* [Array.prototype.slice ()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice)

View File

@@ -0,0 +1,32 @@
---
title: Sort an Array Alphabetically using the sort Method
localeTitle: فرز صفيف أبجديا باستخدام طريقة الفرز
---
## فرز صفيف أبجديا باستخدام طريقة الفرز
### طريقة
في المثال المعطى ، نرى كيف نكتب دالة ستعيد مصفوفة جديدة بترتيب أبجدي معكوس.
`function reverseAlpha(arr) {
return arr.sort(function(a, b) {
return a < b;
});
}
reverseAlpha(['l', 'h', 'z', 'b', 's']);
// Returns ['z', 's', 'l', 'h', 'b']
`
باستخدام هذا المنطق ، ببساطة عكس هندسة وظيفة لإرجاع مجموعة جديدة بالترتيب الأبجدي.
### حل
`function alphabeticalOrder(arr) {
// Add your code below this line
return arr.sort(function(a,b) {
return a > b;
});
// Add your code above this line
}
alphabeticalOrder(["a", "d", "c", "a", "z", "g"]);
`

View File

@@ -0,0 +1,21 @@
---
title: Split a String into an Array Using the split Method
localeTitle: تقسيم سلسلة في صفيف باستخدام طريقة الانقسام
---
## تقسيم سلسلة في صفيف باستخدام طريقة الانقسام
### طريقة
ما عليك سوى تقسيم السلسلة لإنشاء مجموعة جديدة من الكلمات.
يمكن استخدام تعبير عادي بسيط لتحقيق هذه النتيجة.
### حل
`function splitify(str) {
// Add your code below this line
return str.split(/\W/);
// Add your code above this line
}
splitify("Hello World,I-am code");
`

View File

@@ -0,0 +1,51 @@
---
title: Understand Functional Programming Terminology
localeTitle: فهم البرمجة الوظيفية المصطلحات
---
## فهم البرمجة الوظيفية المصطلحات
### طريقة
كما هو الحال في التحدي الأخير ، يجب عليك استدعاء طريقة `getTea` وتخزينها في متغير. فقط هذه المرة ، لديك متغيرين لتخزين مجموعتين `getTea()` من البيانات. سترى أن الدالة `getTea()` هي نفسها كما كانت من قبل ، فقط الآن تأخذ في معلمتين منفصلتين. المعلمة الأولى هي دالة ، لذا سنحتاج إلى المرور في `prepareGreenTea()` أو الوظيفة `prepareBlackTea()` ، متبوعة بالمعلمة الثانية `numOfCups` التي يمكن `numOfCups` صحيح.
### حل
في هذا التمرين ، نقوم بتعيين نتيجة دالة أعلى من الترتيب للمتغيرات. للقيام بذلك ، فإننا نطلق على الدالة وظيفة رد اتصال كمعامل.
## ملحوظة:
`javascript const basketOne = makeBasket(addFruit, 10)`
\## حل:
\`\` \`جافا سكريبت
/ \*\*
* عملية طويلة لتحضير الشاي الأخضر.
* return {string} كوب من الشاي الأخضر. \*\* / const preparGreenTea = () => 'greenTea'؛
/ \*\*
* الحصول على عدد معين من أكواب الشاي.
* param {function (): string} preparTea نوع وظيفة تحضير الشاي.
* param {number} numOfCups عدد أكواب الشاي المطلوبة.
* return {Array } كمية معينة من أكواب الشاي. \*\* / const getTea = (prepareTea، numOfCups) => { const teaCups = \[\]؛
لـ (دع الكؤوس = 1 ؛ أكواب <= numOfCups ؛ أكواب + = 1) { const teaCup = prepareTea ()؛ teaCups.push (فنجان)؛ }
عودة teaCups. }؛
// أضف رمزك أدناه هذا السطر const tea4GreenTeamFCC = getTea (prepareGreenTea، 27)؛ // :) const tea4BlackTeamFCC = getTea (prepareBlackTea، 13)؛ // :) // أضف رمزك فوق هذا الخط
console.log ( tea4GreenTeamFCC، tea4BlackTeamFCC )؛
\`\` \`
## شرح الكود:
في الحل أعلاه مررنا في الوظائف `prepareGreenTea()` و `prepareBlackTea()` كمعلمات أو وظائف رد اتصال لوظائف `getTea()` التي تم تعيينها لمتغيرينا `tea4BlackTeamFCC` و `tea4GreenTeamFCC` . بهذه الطريقة لا تتغير المتغيرات العالمية ، ولدينا خيار لإضافة عدد غير محدود من الخيارات المختلفة من أساليب `prepareTea()` لأنه يتم تمرير وظيفة رد الاتصال إلى وظيفة ترتيب أعلى من `getTea()` .

View File

@@ -0,0 +1,9 @@
---
title: Understand the Hazards of Using Imperative Code
localeTitle: فهم مخاطر استخدام الرمز الاحتمالي
---
## فهم مخاطر استخدام الرمز الاحتمالي
هذا هو كعب. [ساعد مجتمعنا على توسيعه](https://github.com/freecodecamp/guides/tree/master/src/pages/certifications/javascript-algorithms-and-data-structures/functional-programming/understand-the-hazards-of-using-imperative-code/index.md) .
[سيساعدك دليل النمط السريع هذا على ضمان قبول طلب السحب](https://github.com/freecodecamp/guides/blob/master/README.md) .

View File

@@ -0,0 +1,40 @@
---
title: Use the every Method to Check that Every Element in an Array Meets a Criteria
localeTitle: استخدم كل أسلوب للتحقق من أن كل عنصر في صفيف يلبي معايير
---
## استخدم كل أسلوب للتحقق من أن كل عنصر في صفيف يلبي معايير
### شرح المشكلة:
استخدم `every` طريقة داخل وظيفة `checkPositive` للتحقق مما إذا كان كل عنصر في `arr` موجب. يجب أن ترجع الدالة قيمة منطقية.
#### روابط ذات صلة:
* [Array.prototype.every ()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every)
### ملحوظة
لا تنسى `return`
## حل
`function checkPositive(arr) {
// Add your code below this line
return arr.every(val => val > 0);
// Add your code above this line
}
checkPositive([1, 2, 3, -4, 5]);
`
## حل بديل
`function checkPositive(arr) {
// Add your code below this line
return arr.every(function(value) {
return value > 0;
});
// Add your code above this line
}
checkPositive([1, 2, 3, -4, 5]);
`

View File

@@ -0,0 +1,20 @@
---
title: Use the filter method to extract data from an array
localeTitle: استخدم طريقة التصفية لاستخراج البيانات من مصفوفة
---
## استخدم طريقة التصفية لاستخراج البيانات من مصفوفة
## ![:speech_balloon:](https://forum.freecodecamp.com/images/emoji/emoji_one/speech_balloon.png?v=3 ": speech_balloon:") تلميح: 1
يتم حل هذه الحلقتة في خطوتين. أولاً ، يتم استخدام Array.prototype.filter لتصفية الصفيف بحيث يتم تركه مع عناصر تحتوي على imdbRating> 8.0. بعد ذلك ، يمكن استخدام Array.prototype.map لتشكيل الإخراج إلى التنسيق المطلوب.
### حل
`// Add your code below this line
var filteredList = watchList.map(function(e) {
return {title: e["Title"], rating: e["imdbRating"]}
}).filter((e) => e.rating >= 8);
console.log(filteredList);
`

View File

@@ -0,0 +1,26 @@
---
title: Use the map Method to Extract Data from an Array
localeTitle: استخدم الخريطة أسلوب استخراج البيانات من صفيف
---
## استخدم الخريطة أسلوب استخراج البيانات من صفيف
## ![:speech_balloon:](https://forum.freecodecamp.com/images/emoji/emoji_one/speech_balloon.png?v=3 ": speech_balloon:") تلميح: 1
يأخذ array.prototype.map وظيفة كما في المدخلات ويعيد مصفوفة. يتضمن الصفيف الذي تم إرجاعه العناصر التي تتم معالجتها بواسطة الدالة. هذه الوظيفة تأخذ العناصر الفردية كمدخل.
## تنبيه المفسد!
![علامة تحذير](//discourse-user-assets.s3.amazonaws.com/original/2X/2/2d6c412a50797771301e7ceabd554cef4edcd74d.gif)
**الحل في المستقبل!**
## ![:rotating_light:](https://forum.freecodecamp.com/images/emoji/emoji_one/rotating_light.png?v=3 ": rotating_light:") حل الشفرة المتوسطة:
` rating = watchList.map( (item) => ({"title":item["Title"], "rating":item["imdbRating"]}) );
`
\### رمز التوضيح: باستخدام تدوين ES6 ، تتم معالجة كل عنصر في الصفيف لاستخراج العنوان والتقييم. هناك حاجة إلى Parantheses لإرجاع كائن.
#### روابط ذات صلة
* [وظائف السهم](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions)

View File

@@ -0,0 +1,128 @@
---
title: Use the reduce Method to Analyze Data
localeTitle: استخدم تقليل أسلوب تحليل البيانات
---
## استخدم تقليل أسلوب تحليل البيانات
`// 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 = watchList.filter(x => x.Director === "Christopher Nolan").map(x => Number(x.imdbRating)).reduce((x1, x2) => x1 + x2) / watchList.filter(x => x.Director === "Christopher Nolan").length;
// Add your code above this line
console.log(averageRating);
`

View File

@@ -0,0 +1,21 @@
---
title: Use the some Method to Check that Any Elements in an Array Meet a Criteria
localeTitle: استخدم بعض الأسلوب للتحقق من أن أي عناصر في مصفوفة تطابق معايير
---
## استخدم بعض الأسلوب للتحقق من أن أي عناصر في مجموعة تطابق معايير
### شرح المشكلة
استخدم بعض الطريقة داخل وظيفة checkPositive للتحقق مما إذا كان أي عنصر في arr موجبًا. يجب أن ترجع الدالة `checkPositive` قيمة منطقية.
#### روابط ذات صلة:
* [Array.prototype.some ()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
### حل:
`function checkPositive(arr) {
return arr.some((elem) => elem > 0);
}
checkPositive([1, 2, 3, -4, 5]);
`