I have a data like this:
{
"countries": {
"US": {
"details": {
"code": 1,
"population": ""
},
"people": [
{
"name": ""
},
{
"name": ""
}
]
},
"UK": {
"details": {
"code": 44,
"population": ""
},
"people": [
{
"name": ""
},
{
"name": ""
}
]
}
}
}
I want to loop through it and extract people
so I can loop through the people and display them on the site.
var countries = {
"countries": {
"US": {
"details": {
"code": 1,
"population": ""
},
"people": [
{
"name": ""
},
{
"name": ""
}
]
},
"UK": {
"details": {
"code": 44,
"population": ""
},
"people": [
{
"name": ""
},
{
"name": ""
}
]
}
}
}
for (let [key, value] of Object.entries(countries.countries)) {
//console.log(value);
for (var people in value.people) {
console.log(people);
}
}
But I keep getting 0, 1, how can I get the value of people
array?