Files
freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-and-data-structures/basic-javascript/access-array-data-with-indexes.md
2023-02-16 12:04:56 +01:00

2.1 KiB

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

--description--

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

array indexes تكتب بنفس الأقواس التي تستخدم في المقاطع النصية (strings)، باستثناء أنه بدلاً من تحديد رمز، فإنهم يحددون عنصرا في القائمة (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];