5. Who's in your bracket?


I'm having an issue with this part. The console prints the job property but it gives me an error message "Oops, try again.
Do you have the variable 'aProperty' between brackets?" so I'm not sure why it isn't working. Can someone clarify this for me a little? Heres my code.

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

// set to the first property name of "james"
var aProperty = james["job"];

// print the value of the first property of "james"
// using the variable "aProperty"


You will be getting 'programmer' from james["job"], so will throw a ReferenceError since there is no property name, 'programmer'.

aProperty = "job"

Now james[aProperty] will be programmer.


doing exactly as you said and it keeps telling me :
slightly_smiling:Oops, try again. It looks like james' job was not logged to the console.
A problem from code academy?


post your code, and lets see what the problem is :slightly_smiling:


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

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

// print the value of the first property of "james"
// using the variable "aProperty"


works fine for me, copy your code then try refreshing your browser, or clearing caches by pressing ctrl f5 paste your code back in and see if it lets you pass.


Thx works now after refreshing the page.


Hum. Thanks. I think the exercice is not very clear.


OMG... Thank YOU.

The forums are my last resort. But I was going crazy.

This is really bad that you need to refresh the page for the code to work.

Learning JS is hard enough debugging your own code without having to second guess if the site is working correctly...


works fine after refreshing the page.....

codeacademy needs to resolve this problem as well.


Just looking for some clarification on why this aProperty = "job" works in this manner and is not just read as a variable with a string of "job"? There must be something I missed along the way.


When accessing a property with subscript notation, we have to quote the strings:


We can assign the string to a variable, in this case, aProperty and use the variable in the subscript:

aProperty = "job";

We would normally use dot notation when accessing properties directly; however, in a for..in statement we use a key iterator variable, so must use subscript notation.

for (var key in james) {
    console.log(key, james[key]);

Making sense?


+1 on the tutorial being confusing and the super annoyance of having to refresh the page


Glad you got through. It's thanks to the hard work you put forward.