--- id: 56533eb9ac21ba0edf2244cd title: Accessing Nested Arrays localeTitle: Acceso a matrices anidadas challengeType: 1 guideUrl: 'https://spanish.freecodecamp.org/guide/certificates/access-array-data-with-indexes' --- ## Description
Como hemos visto en ejemplos anteriores, los objetos pueden contener tanto objetos anidados como matrices anidadas. Al igual que para acceder a objetos anidados, la notación de paréntesis de arrays se puede encadenar para acceder a arrays anidados. Aquí hay un ejemplo de cómo acceder a una matriz anidada:
var ourPets = [
  {
    animalType: "cat",
    names: [
      "Meowzer",
      "Fluffy",
      "Kit-Cat"
    ]
  },
  {
    animalType: "dog",
    names: [
      "Spot",
      "Bowser",
      "Frankie"
    ]
  }
];
ourPets[0].names[1]; // "Fluffy"
ourPets[1].names[0]; // "Spot"
## Instructions
Recupere el segundo árbol de la variable myPlants usando el punto de objeto y la notación de corchete de matriz.
## Tests
```yml tests: - text: secondTree debe ser igual a "pino" testString: 'assert(secondTree === "pine", "secondTree should equal "pine"");' - text: Use la notación de puntos y corchetes para acceder a 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 var myPlants = [ { type: "flowers", list: [ "rose", "tulip", "dandelion" ] }, { type: "trees", list: [ "fir", "pine", "birch" ] } ]; // Only change code below this line var secondTree = myPlants[1].list[1]; ```