Accessing Nested Arrays challenge

Accessing Nested Arrays challenge


Why is the example code in this challenge:

var ourPets = [
    animalType: "cat",
    names: [
    animalType: "dog",
    names: [

considered a nested array and not a nested object?


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.


Thanks for clearing that up.

Much appreciated.