How can i iterate over the following using Javascript to count the number of teams?

Sunday, May 4, 2014


var data = {
"name": "nba",
"conference": [
{
"name": "Eastern",
"divisions": [
{
"name": "Atlantic",
"teams": [
{
"location": "Brooklyn",
"name": "Nets"
},
{
"location": "Boston",
"name": "Celtics"
},
{
"location": "New York",
"name": "Knicks"
},
{
"location": "Philadelphia",
"name": "76ers"
},
{
"location": "Toronto",
"name": "Raptors"
}
]
},
{
"name": "Central",
"teams": [
{
"location": "Chicago",
"name": "Bulls"
},
{
"location": "Cleveland",
"name": "Cavaliers"
},
{
"location": "Detroit",
"name": "Pistons"
},
{
"location": "Indiana",
"name": "Pacers"
},
{
"location": "Milwaukee",
"name": "Bucks"
}
]
},
{
"name": "Southeast",
"teams": [
{
"location": "Atlanta",
"name": "Hawks"
},
{
"location": "Charlotte",
"name": "Bobcats"
},
{
"location": "Miami",
"name": "Heat"
},
{
"location": "Orlando",
"name": "Magic"
},
{
"location": "Washington",
"name": "Wizards"
}
]
}
]
},
{
"name": "Western",
"divisions": [
{
"name": "Northwest",
"teams": [
{
"location": "Denver",
"name": "Nuggets"
},
{
"location": "Minnesota",
"name": "Timberwolves"
},
{
"location": "Oklahoma City",
"name": "Thunder"
},
{
"location": "Portland",
"name": "Trailblazers"
},
{
"location": "Utah",
"name": "Jazz"
}
]
},
{
"name": "Pacific",
"teams": [
{
"location": "Golden State",
"name": "Warriors"
},
{
"location": "Los Angeles",
"name": "Clippers"
},
{
"location": "Los Angeles",
"name": "Lakers"
},
{
"location": "Phoenix",
"name": "Suns"
},
{
"location": "Sacramento",
"name": "Kings"
}
]
},
{
"name": "Southwest",
"teams": [
{
"location": "Dallas",
"name": "Mavericks"
},
{
"location": "Houston",
"name": "Rockets"
},
{
"location": "Memphis",
"name": "Grizzlies"
},
{
"location": "New Orleans",
"name": "Pelicans"
},
{
"location": "San Antonio",
"name": "Spurs"
}
]
}
]
}
]
};






http://ift.tt/1mtaRfE