Accessing Object Properties with Dot Notation

Accessing Object Properties with Dot Notation
0.0 0

#1

// 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


#2

What is your question?


#3

If you know the name of an object property you can access that value one of two ways. Dot notation or bracket notation. The test is to change the bracket notation to dot notation.

const person = {name:"Bob", job:"Secret Agent"};

//both of these will work
console.log(person.name);  //  Bob ( . dot notation)
console.log(person["name"]);  //  Bob ( [] bracket notation)

#4

I was wondering whether my good was solid or not…thanks for your concern !


#5

Use " ,instead of “ . Wrong characters.