I want to map and convert the below JSON structure to array of simple string but getting the undefined error while mapping.
JSON structure :
var yourArray = [
{
"options": [
{
'id':1,
'name':'All'
},{
'id':2,
'name':'Javascript'
},{
'id':2000,
'name':'Ruby'
}
]
}
];
Trying to map like this :
var newArray = yourArray.map( function( el ){
yourArray.options.map( function( eln ){
return eln.name;
})
});
console.log (newArray);
Note: Following this example How do I convert a javascript object array to a string array of the object attribute I want?