83 lines
2.5 KiB
Markdown
83 lines
2.5 KiB
Markdown
|
---
|
||
|
id: 56533eb9ac21ba0edf2244cd
|
||
|
title: Accessing Nested Arrays
|
||
|
challengeType: 1
|
||
|
guideUrl: 'https://arabic.freecodecamp.org/guide/certificates/access-array-data-with-indexes'
|
||
|
videoUrl: ''
|
||
|
localeTitle: الوصول إلى صفائف متداخلة
|
||
|
---
|
||
|
|
||
|
## Description
|
||
|
<section id="description"> كما رأينا في الأمثلة السابقة ، يمكن أن تحتوي الكائنات على كل من الكائنات المتداخلة والصفائف المتداخلة. على غرار الوصول إلى الكائنات المتداخلة ، يمكن تقييد تدرج قوس Array للوصول إلى صفائف متداخلة. فيما يلي مثال لكيفية الوصول إلى صفيف متداخل: <blockquote style=";text-align:right;direction:rtl"> var ourPets = [ <br> { <br> animalType: "قطة" ، <br> الأسماء: [ <br> "Meowzer" <br> "رقيق"، <br> "كيت كات" <br> ] <br> }، <br> { <br> animalType: "dog" ، <br> الأسماء: [ <br> "بقعة"، <br> "العربة"، <br> "فرانكي" <br> ] <br> } <br> ]. <br> ourPets [0] .names [1]؛ // "رقيق" <br> ourPets [1] .names [0]؛ // "سبوت" </blockquote></section>
|
||
|
|
||
|
## Instructions
|
||
|
<section id="instructions"> استرجاع الشجرة الثانية من <code>myPlants</code> المتغير باستخدام <code>myPlants</code> نقطة الكائن <code>myPlants</code> مجموعة الصفيف. </section>
|
||
|
|
||
|
## Tests
|
||
|
<section id='tests'>
|
||
|
|
||
|
```yml
|
||
|
tests:
|
||
|
- text: <code>secondTree</code> ينبغي أن يساوي "الصنوبر"
|
||
|
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>");'
|
||
|
|
||
|
```
|
||
|
|
||
|
</section>
|
||
|
|
||
|
## Challenge Seed
|
||
|
<section id='challengeSeed'>
|
||
|
|
||
|
<div id='js-seed'>
|
||
|
|
||
|
```js
|
||
|
// 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
|
||
|
|
||
|
```
|
||
|
|
||
|
</div>
|
||
|
|
||
|
|
||
|
### After Test
|
||
|
<div id='js-teardown'>
|
||
|
|
||
|
```js
|
||
|
console.info('after the test');
|
||
|
```
|
||
|
|
||
|
</div>
|
||
|
|
||
|
</section>
|
||
|
|
||
|
## Solution
|
||
|
<section id='solution'>
|
||
|
|
||
|
```js
|
||
|
// solution required
|
||
|
```
|
||
|
</section>
|