Files
freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-and-data-structures/basic-javascript/access-array-data-with-indexes.md
2022-10-20 09:13:17 -07:00

2.2 KiB

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
56bbb991ad1ed5201cd392ca الوصول إلى بيانات القائمة باستخدام الترتيب (Access Array Data with Indexes) 1 https://scrimba.com/c/cBZQbTz 16158 access-array-data-with-indexes

--description--

يمكننا الوصول إلى البيانات داخل القائمات باستخدام الترتيب.

Array indexes تكتب بنفس الأقواس التي تستخدم في مقاطع النصية (strings)، باستثناء أنه بدلاً من تحديد رمز، فإنهم يحددون عنصرا في القائمة (array). مثل المقاطع النصية (strings)، فإن القائمات (arrays) تستخدم القائمة تبدأ بالصفر، لذا فإن العنصر الأول في القائمة (array) لديه الترتيب (index) برقم 0.


على سبيل المثال

const array = [50, 60, 70];
console.log(array[0]);
const data = array[1];

console.log(array[0]) تطبع 50 و data بقيمة 60.

--instructions--

أنشئ متغير يسمى myData وعيّنه ليساوي القيمة الأولى في myArray باستخدام bracket notation.

--hints--

المتغير myData يجب أن يساوي القيمة الأولى في myArray.

assert(
  (function () {
    if (
      typeof myArray !== 'undefined' &&
      typeof myData !== 'undefined' &&
      myArray[0] === myData
    ) {
      return true;
    } else {
      return false;
    }
  })()
);

البيانات في المتغير myArray يجب الوصول إليها باستخدام bracket notation.

assert(
  (function () {
    if (code.match(/\s*=\s*myArray\[0\]/g)) {
      return true;
    } else {
      return false;
    }
  })()
);

--seed--

--after-user-code--

if(typeof myArray !== "undefined" && typeof myData !== "undefined"){(function(y,z){return 'myArray = ' + JSON.stringify(y) + ', myData = ' + JSON.stringify(z);})(myArray, myData);}

--seed-contents--

const myArray = [50, 60, 70];


--solutions--

const myArray = [50, 60, 70];
const myData = myArray[0];