Accessing Object Properties with Bracket Notation

Tell us what’s happening:

Your code so far


// Setup
var testObj = {
  "an entree": "hamburger",
  "my side": "veggies",
  "the drink": "water"
};

// Only change code below this line

var entreeValue = testObj.entreeValue;   // Change this line
var drinkValue = testObj.drinkValue;    // Change this line

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/accessing-object-properties-with-bracket-notation

There is no property named entreevalue or drinkvalue in the testObj
So that won’t work. I suggest you reread this challenge from the start because you have missed the point of what is being taught.

1 Like

You didn’t assign the values to entreeValue and drinkValue using bracket, you used dot. Read my code below for more understanding:

// Setup
var testObj = {
  "an entree": "hamburger",
  "my side": "veggies",
  "the drink": "water"
};

// Only change code below this line

 var entreeValue = testObj["an entree"];   // Change this line
 var drinkValue = testObj["the drink"];    // Change this line