JavaScript - How to use Map instead of For Loop -


i want use map instead of loop in example. have csv files contains data

csv file address,type,building,geometry "this","is","an","example" "this","is","an","example" "this","is","an","example" "this","is","an","example" "this","is","an","example" "this","is","an","example" "this","is","an","example"  var geojsonfeature;  var globaldata= data.map(function(d){return json.parse(d.geometry);}); var buildingdata= data.map(function(d){return json.parse(d.type);});   (i=0;i<globaldata.legnth;i++) { geojsonfeature = {         "type": "feature",         "properties": {             "name": buildingdata[i]         },         "geometry": {             "type": "multipolygon",             "coordinates": globaldata[i].coordinates         }     };   listgeodata.push(geojsonfeature)  } 

i wanted replace for-loop map "listgeodata" way.

this assumes listgeodata empty prior for loop.

var listgeodata = globaldata.map(function(data,i) {   return {     "type": "feature",     "properties": {       "name": buildingdata[i]     },     "geometry": {       "type": "multipolygon",       "coordinates": data.coordinates     }   }; }); 

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -