In populate()
function of service.js, I was trying to build an object array to store the passengers' name
, house
, placemark
and marker
. Basically, I created a global array, say database[]
, then when iterating through every passenger's information in PASSENGERS[]
,I add both the property and value dynamically:
database[i].name = PASSENGERS[i].name;
database[i].house = PASSENGERS[i].house;
database[i].placemark = placemark;
database[i].marker = marker;
When I validate the code using 'Inspect Elements' on Google, it pops out the message:
Uncaught TypeError:Cannot set property 'name' of undefined.
Is that the correct way to declare an object array? Or is there anything wrong with adding new property and values? Much appreciated.