1

I created this JavaScript object that contains key/value pairs. The keys are the states and the values are arrays of the cities within each state.

I have included a link to my code on JSFiddle, but the basic structure of my object looks like this:

var location = {
    "Key":[],
    "Key":[], 
}

JsFiddle

  1. Have I set up my object correctly?

  2. There's something wrong with the key/value pair for 'MG.' I can't figure out what, though. When I look at the color-coded code, the second half of that line is black (starting at ', "Santa Maria do Suaçuí"' while the rest displays as expected.

I will greatly appreciate any feedback that can get my gears turning, again.

Thank you!

Mike B
  • 2,756
  • 2
  • 16
  • 28
user3472810
  • 435
  • 1
  • 5
  • 13

2 Answers2

3

There is nothing wrong, just a limitation of the editor, try removing one string before and you will see the color will match the next string.

One alternative, would be to write one long string with a delimiter:

'string1|string2|string3'.split('|');  // ['string1', 'string2', 'string3']
Washington Guedes
  • 4,254
  • 3
  • 30
  • 56
1

Your object is set up properly, you can access its properties in this way:

//for example property 'AC' at index 0

location["AC"][0] //returns Acrelândia
vasekhlav
  • 419
  • 4
  • 12