how to loop through objects instead of an array?
$(function() {
var alreadyFilled = false;
var states = ['Alabama','Alaska','American Samoa','Arizona'];
function initDialog() {
clearDialog();
for (var i = 0; i < states.length; i++) {
$('.dialog').append('<div>' + states[i] + '</div>');
}
}
initDialog();
});
here is object i need to loop through instead of above array.
var states_2 = {
'Germany': ['Duesseldorf', 'Leinfelden-Echterdingen', 'Eschborn'],
'Spain': ['Barcelona'],
'Hungary': ['Pecs'],
'USA': ['Downers Grove'],
'Mexico': ['Puebla'],
}