I am trying to get a specific field value from a nested array within an object array. I\'m assuming I\'d use map, but every time I use it in this way I get two empty arrays nest
A quick function to return an item with the desired property and value of that property :
data = [{id:1,name:'Bob',hobbies:['a','b']},{id:2,name:'Alice',hobbies:['c','d']}];
function getPerson(property,value){
for(var i=0;i
And a test :
console.log(getPerson('name','Bob'));
console.log(getPerson('name','Bob').hobbies);