Why is undefined being logged?


#1


https://www.codecademy.com/courses/objects-ii/0/5?curriculum_id=506324b3a7dffd00020bf661


Oops, try again. It looks like james' job was not logged to the console.


var james = {
    job: "programmer",
    married: false
};

// set to the first property name of "james"
var aProperty = "programmer";

// print the value of the first property of "james" 
// using the variable "aProperty"
console.log(james[aProperty]);


Here's what's logging into my console


undefined


#2

To access value we use key.

"programmer" is a value.

you need to save key in aProperty which is job? (It should be string!)


#4

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