Tell us what’s happening:
Hi everyone,
for this challenge, I don’t understand why when use dot notation, I can’t use quotation marks (for example, var hatValue=testObj.“hat”) . Even though the property was described as “hat”, why couldn’t I use “” when I try to call it?
And why in the bracket case, however, you are required to use the quotation mark to call a property?
Thanks anyone who could help.
Your code so far
// Setup
var testObj = {
“hat”: “ballcap”,
“shirt”: “jersey”,
“shoes”: “cleats”
};
// Only change code below this line
var hatValue = testObj.“hat”; // Change this line
var shirtValue = testObj.“shirt”; // Change this line
// Setup
var testObj = {
"hat": "ballcap",
"shirt": "jersey",
"shoes": "cleats"
};
// Only change code below this line
var hatValue = testObj."hat"; // Change this line
var shirtValue = testObj."shirt"; // Change this line
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36
.
Challenge: Accessing Object Properties with Dot Notation
Link to the challenge: