Find a value in json object using lodash methods flatten and find -


using lodash want find team id 3229. tried following not returning anything.

    var team = _.chain(data.teams)         .flatten("divisionteams")         .find({"id":3229})         .value(); 

here plunker code.

http://plnkr.co/edit/udwzrkx3zkyjyf8uwo7i

for json data please see file data.js in plunker.

please note cannot change json data since calling test api.

flatten doesn't take argument, see docs. need either map or pluck divisionteams.

_.chain(data.teams) .pluck('divisionteams') .flatten() .find({id: 3232}) .value(); 

Comments

Popular posts from this blog

c# - ItextSharp font color issue in ver 5.5.4+ -

jquery - Multiple issues with pushstate: history, loading, calling functions -

ios - retrievePeripherals deprecated in IOS7 how to substitude it with retrievePeripheralsWithIdentifiers -