Mr.KGK Mr.KGK - 5 months ago 11
Javascript Question

For Each loop ---> For loop Urgent Need

I am having a error that states that data.forEach is not a function. The code is:

The code that I edited:
Code

The error with console.log(data)
Error

Answer

data is an object. It looks like you want to loop over the features array within that object, so do:

data.features.forEach(function(element, index) {
    isoGeojson.features[index] = {
        type: 'Feature',
        properties: element.properties,
        geometry: {
            type: 'MultiPolygon',
            coordinates: element.coordinates.slice()
        }            
    }
});