Accessing Nested Arrays challenge

Accessing Nested Arrays challenge
0

#1

Why is the example code in this challenge:

var ourPets = [
  {
    animalType: "cat",
    names: [
      "Meowzer",
      "Fluffy",
      "Kit-Cat"
    ]
  },
  {
    animalType: "dog",
    names: [
      "Spot",
      "Bowser",
      "Frankie"
    ]
  }
];

considered a nested array and not a nested object?


#2

Because ourPets is an array (see the square bracket after the assignment operator). It has two elements, both are objects, but each element can be accessed by using the array name and the element index: ourPets[0] and ourPets[1]. Command console.log(ourPets[1]) would work and return the object that stores information about dogs. console.log(ourPets[“names”]) would NOT work as ourPets is not an object.


#3

Thanks for clearing that up.

Much appreciated.