I want to loop through a JSON like this using javascript.
{
persons: [
Person {
name: 'Herbert',
age: 70
},
Person {
name: 'Peter',
age: 67
}
]
}
My first approach was something like this, but this is not working somehow :(
personArray.forEach((person) => {
console.log(person.name);
});
Person: {? Also what is personArray? Should we assume it's the array in the JSON object with keyperson?[{name:'',age:''},{name:'',age:''}...]. if soyourmainobj.persons.forEach...