Return filtered array in javascript -


i though going straightforward. have dataset containing (foreach country) name, imfcode, lat,lon. want pass code function filter dataset returning info correspond code passed it. if pass 512 should information relating afganistan. here function, mind telling me i'm doing wring

function loadtrade(imfcode) {   console.log ("country code= ",imfcode)   var sourcecountry=dataset.filter function(el){     return el.imfcode===imfcode   }   console.log ("source country= ",sourcecountry) } 

i keep getting unexpected token , can't see it. many thanks

you missed parenthesis after dataset.filter

change :

function loadtrade(imfcode) {   console.log ("country code= ",imfcode)   var sourcecountry=dataset.filter(function(el){     return el.imfcode===imfcode;   });   console.log ("source country= ",sourcecountry); } 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -