0

Conceptually: What is the difference between their format? (Array of objects? vs. ???) Been struggling to qualify this.

Practically: I understand how to retrieve data in passengers.js but have been having trouble accessing the information I want in houses.js. For example, individual PASSENGERS can be accessed PASSENGERS[i], where i is an integer, but that will not work for HOUSES

It would be helpful if someone could explain the difference conceptually and show a few practical examples. Thanks.

Ex. PASSENGERS[0] returns the first passenger in what appears to me to be an array of objects. HOUSES[0] returns undefined.

1

You can think of HOUSES as an associative array. It contains key/value pairs. The keys are the strings (e.g., "Adams House", "Cabot House", etc.) and the values are the objects that are mapped to these strings. To access the object that is mapped to a string, you may use something like

var house = HOUSES["Adams House"];

Each of these objects contains two properties, lat and lng. To access any of these properties, you may use something like

house.lat; // access the lat property
house.lng; // access the lng property

For more information about properties and the ways you can access them, you may read this!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .