Objects with Quotes around Keys?

Tell us what’s happening:
Can anyone tell me why the keys here (“artist”, “title”, etc) are enclosed in quotes? I was under the impression that keys didn’t get quotes. I also noticed that a few exercises after this exercise, the exercise for accessing nested arrays, that the keys are not enclosed in quotes. How do I know when to enclose keys in quotes and when not to? Thanks everyone for your time and input!

Your code so far

var myMusic = [
  {
    "artist": "Billy Joel",
    "title": "Piano Man",
    "release_year": 1973,
    "formats": [ 
      "CS", 
      "8T", 
      "LP" ],
    "gold": true
  },
  // Add record here
  {"artist": "Josh Ritter",
   "title": "The Animal Years",
   "release_year": 2006,
   "formats": ["CD", "Digital"]
  
  }
];

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://www.freecodecamp.org/challenges/manipulating-complex-objects

You can refer to properties in the object using both of these:

myMusic[0].artist // Billy Joel
myMusic[0]["artist"] // Billy Joel

Similarly we could also express the object as:

var myMusic = [
  {
    artist: "Billy Joel",
    title: "Piano Man",
    release_year: 1973,
    format: [ 
      "CS", 
      "8T", 
      "LP" ],
    gold: true
  }
]

and then reference this in the same way:

myMusic[0].artist // Billy Joel
myMusic[0]["artist"] // Billy Joel

The quotes style in your example is what JSON looks like. JSON is a format for expressing data that looks very similar to JavaScript. This is what API’s typically return data in. The flexibility of being able to use JSON and JS objects interchangeably is convenient when dealing with API’s.

In code, generally you should use the no-quotes style. Just be aware that the other style works also. It will make sense later when you deal with getting data from servers.

Thanks collinstommy and randelldawson for the replies, these were very helpful!