Seeking some guidance as I navigate through unlabelled data for the first time. The challenge lies in determining the total count of department_count from the JSON object below.
No matter how many solutions I try or logic I implement, I keep running into roadblocks and failing to retrieve the desired output.
With a total of 3 departments, the expected result should be 3. An alternative approach is to calculate the sum of department_count in each iteration.
THE DESIRED RESULT IS 3
var myObject =[
{
"school_id":"1",
"school_name":"XYZ",
"department_count":1,
"department":[
{
"id":"stu1",
"name":"sammy",
"height":88,
"weight":2,
"bmi":1,
"type":"Healthy"
}
]
},
{
"school_id":"2",
"school_name":"ABC",
"department_count":2,
"department":[
{
"id":"stu2",
"name":"Sam",
"height":5,
"weight":2,
"bmi":1,
"type":"Skinny"
},
{
"id":"stu3",
"name":"REd",
"height":0,
"weight":0,
"bmi":0,
"type":""
}
]
}
]