I have this json data
myObj = {
"job":[
{
"student":{
"name" : "Agus"
}
},
{
"lecturer":{
"name" : "Budi"
}
}
]
}
how to forEach the object and print out the property of "name" value
I have this json data
myObj = {
"job":[
{
"student":{
"name" : "Agus"
}
},
{
"lecturer":{
"name" : "Budi"
}
}
]
}
how to forEach the object and print out the property of "name" value
Here is a working example:
const myObj = {
"job": [
{
"student": {
"name": "Agus"
}
},
{
"lecturer": {
"name": "Budi"
}
}
]
}
myObj.job.forEach((element) => {
const keys = Object.keys(element);
keys.forEach((key) => {
console.log(element[key].name);
})
});