I retrieved objects and pushed them into another object and I tried to loop over the new object using the "for in-looop" however it does not loop over the code.
my object
var allControls = {}
How I retrieved data from my firebase database
var controlRef = database.ref('Controls');
controlRef.on('value', function(snapshot) {
snapshot.forEach(function(childSnapshot) {
var control = childSnapshot.val();
allControls[control.name] = control;
_newMarker = L.marker(control.LatLong,
{title: control.name,
riseOnHover: true,
icon: markerIcon},).addTo(mymap);
my for loop which does not run
for (var i in allControls){
console.log(allControls[i])
var data = allControls[i];
console.log(data)
var icon = L.icon({
// iconUrl: data.icon,
iconSize: [52, 60], // size of the icon
iconAnchor: [26, 60], // point of the icon which will correspond to marker's location
popupAnchor: [0, -60]
});
if (data.iconori === "left") {
icon = L.icon({
// iconUrl: data.icon,
iconSize: [60, 52],
iconAnchor: [60, 26],
popupAnchor: [-35, -26]
});
};
if (data.iconori === "right") {
icon = L.icon({
// iconUrl: data.icon,
iconSize: [60, 52],
iconAnchor: [0, 26],
popupAnchor: [35, -26]
})
};
}
any ideas why my loop might not run?