Basic JavaScript - Accessing Object Properties with Dot Notation

Tell us what’s happening:

I don’t understand this. The instructions state that hatValue should be the string ballcap. Why then is the answer const hatValue = testObj.hat; ?

Thanks for anyone’s time!

Your code so far

// Setup
const testObj = {
  "hat": "ballcap",
  "shirt": "jersey",
  "shoes": "cleats"
};

// Only change code below this line
const hatValue = testObj.hat;      // Change this line
const shirtValue = testObj.shirt;    // Change this line

Your browser information:

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

Challenge Information:

Basic JavaScript - Accessing Object Properties with Dot Notation

What is the hat property of testObj?

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.