'How to loop through "users" and return the value of each "name"
I am trying to loop through "users" and return the value of each "name".
From what I can tell the loop works, but when returning the value of "name" it comes up as "undefined" four times.
JS:
for(var i = 0; i < customer.users.length; i++){
console.log(customer.users.name)
}
JSON:
{
"users":[
{
"user_id": "123",
"name": "test",
"xp_amount": 25
},
{
"user_id": "456 ",
"name": "test1",
"xp_amount": 25
},
{
"user_id": "789",
"name": "test2",
"xp_amount": 25
},
{
"user_id": "101",
"name": "test3",
"xp_amount": 25
}
]
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
