JSFiddle - React, Tailwind, and code Playground
JavaScript
var data = [
{
"country":"Andorra",
"code":"AD",
"state":[
{
"state_code":"AD1",
"state_description":"aaAndorra1"
},
{
"state_code":"AD2",
"state_description":"aaAndorra2"
}
]
}
]
var result = data.reduce(function(ar, d) {
d.state.forEach(function(s){
ar.push(s.state_code)
});
return ar;
}, [])
console.log(result);