5
{
"USA":[{"country":"Albuquerque (ABQ)"},
        {"country":"Allentown (ABE)"}
        ],
"Canada":{"country":"Calgary (YYC)"},
"Hawaii":{"country":"Honolulu International Apt (HNL)"}
}

This is my object I need to loop it through so i can get all the values like this

USA

  • Albuquerque (ABQ)
  • Allentown (ABE)

Canade

  • Calgary (YYC)
astonish
  • 223
  • 2
  • 8

2 Answers2

3

For the solution you can check out this demo.

DEMO

You can loop Object using for(k in obj)

for(k in obj){
    var value = obj[k];
}
Chokchai
  • 1,684
  • 12
  • 12
1

I have created a jsfiddle for you at http://jsfiddle.net/5eM4q/

The way you access the data using

    data[obj].country

is incorrect

Rajesh
  • 3,743
  • 1
  • 24
  • 31