freeCodeCamp/curriculum/challenges/arabic/02-javascript-algorithms-an.../basic-javascript/accessing-nested-arrays.ara...

2.5 KiB

id title challengeType guideUrl videoUrl localeTitle
56533eb9ac21ba0edf2244cd Accessing Nested Arrays 1 https://arabic.freecodecamp.org/guide/certificates/access-array-data-with-indexes الوصول إلى صفائف متداخلة

Description

كما رأينا في الأمثلة السابقة ، يمكن أن تحتوي الكائنات على كل من الكائنات المتداخلة والصفائف المتداخلة. على غرار الوصول إلى الكائنات المتداخلة ، يمكن تقييد تدرج قوس Array للوصول إلى صفائف متداخلة. فيما يلي مثال لكيفية الوصول إلى صفيف متداخل:
var ourPets = [
{
animalType: "قطة" ،
الأسماء: [
"Meowzer"
"رقيق"،
"كيت كات"
]

{
animalType: "dog" ،
الأسماء: [
"بقعة"،
"العربة"،
"فرانكي"
]
}
].
ourPets [0] .names [1]؛ // "رقيق"
ourPets [1] .names [0]؛ // "سبوت"

Instructions

استرجاع الشجرة الثانية من myPlants المتغير باستخدام myPlants نقطة الكائن myPlants مجموعة الصفيف.

Tests

tests:
  - text: <code>secondTree</code> ينبغي أن يساوي &quot;الصنوبر&quot;
    testString: 'assert(secondTree === "pine", "<code>secondTree</code> should equal "pine"");'
  - text: استخدم نقطة <code>myPlants</code> قوس للوصول إلى <code>myPlants</code>
    testString: 'assert(/=\s*myPlants\[1\].list\[1\]/.test(code), "Use dot and bracket notation to access <code>myPlants</code>");'

Challenge Seed

// Setup
var myPlants = [
  {
    type: "flowers",
    list: [
      "rose",
      "tulip",
      "dandelion"
    ]
  },
  {
    type: "trees",
    list: [
      "fir",
      "pine",
      "birch"
    ]
  }
];

// Only change code below this line

var secondTree = ""; // Change this line

After Test

console.info('after the test');

Solution

// solution required