Updating Object Properties

Tell us what’s happening:

I came up with a question as I’m going through creating js objects.
Why do we keep double quotes around the property names? I’ve quickly looked up syntax in creating an object, and none of references I took have " " around the properties. They rather suggest that we use a variable name without " ".
It seems working fine with “property” in the console but is it one of the proper way doing it?

Your code so far

// Example
var ourDog = {
  "name": "Camper",
  "legs": 4,
  "tails": 1,
  "friends": ["everything!"]

ourDog.name = "Happy Camper";

// Setup
var myDog = {
  "name": "Coder",
  "legs": 4,
  "tails": 1,
  "friends": ["Free Code Camp Campers"]

// Only change code below this line.

Your browser information:

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

Link to the challenge:

As long as the property name is all one string with no other punctuation other than an underscore, you can leave off the quotes. The following work without " " or ’ ':

var myDog = {
  name: "Coder",
  legs: 4,
  tail_length: 10,
  friends: ["Free Code Camp Campers"]

The following would not work without the " " or ’ ':

var myDog = {
  "tail-length": 10,
  "best friends": ["Free Code Camp Campers"]
1 Like