--- id: 56533eb9ac21ba0edf2244cd title: Accessing Nested Arrays challengeType: 1 videoUrl: '' localeTitle: Acessando matrizes aninhadas --- ## Description
Como vimos nos exemplos anteriores, os objetos podem conter tanto objetos aninhados quanto matrizes aninhadas. Semelhante ao acesso a objetos aninhados, a notação de colchetes da Array pode ser encadeada para acessar matrizes aninhadas. Aqui está um exemplo de como acessar uma matriz aninhada:
var ourPets = [
{
animalTipo: "gato",
nomes: [
"Meowzer",
"Fofo",
"Kit-Cat"
]
}
{
animalTipo: "cachorro",
nomes: [
"Local",
"Bowser",
"Frankie"
]
}
];
ourPets [0] .nomes [1]; // "Fofo"
ourPets [1] .nomes [0]; // "Local"
## Instructions
Recuperar a segunda árvore da variável myPlants usando ponto de objeto e notação de colchetes de matriz.
## Tests
```yml tests: - text: secondTree deve ser igual a "pine" testString: 'assert(secondTree === "pine", "secondTree should equal "pine"");' - text: Use a notação de pontos e colchetes para acessar myPlants testString: 'assert(/=\s*myPlants\[1\].list\[1\]/.test(code), "Use dot and bracket notation to access myPlants");' ```
## Challenge 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 ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ```