image below is the console result. Let say I want to print result for department which contain vary answers (example 1A, 2B, 3C). So how to know the length of each inside department? The length of 1A, the length of 2B and so on.
I am trying do like this but error.
var department = response.data[0].department['1A'].length;
console.log(department)
$("#department").text(department);
var department2 = response.data[0].department['1B'].length;
console.log(department2)
$("#department2").text(department2);
JSON
{
"status": "Success",
"data": [
{
"user_id": 3,
"address_line1": null,
"address_line2": null,
"country": null,
"date_of_birth": null,
"department": "1A",
"district": null,
"gender": "Male",
"workgroup": "AM",
"name": "Michael"
},
{
"user_id": 4,
"address_line1": null,
"address_line2": null,
"country": null,
"date_of_birth": null,
"department": "2B",
"district": null,
"gender": "Male",
"workgroup": "MGR",
"name": "Mike"
},
{
"user_id": 5,
"address_line1": null,
"address_line2": null,
"country": null,
"date_of_birth": null,
"department": "3C",
"district": null,
"gender": "Female",
"workgroup": "AGM",
"name": "Rachel"
},
{
"user_id": 6,
"address_line1": null,
"address_line2": null,
"country": null,
"date_of_birth": null,
"department": "3C",
"district": null,
"gender": "Male",
"workgroup": "AGM",
"name": "Joe"
}
]
}


response.data[0].user_privilege['1A'].length;matchresponse.data[0].department?console.log(JSON.stringify(obj, null, 2)).