I don't understand where is Error


#1

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"
console.log(aProperty);

Instruction
Take advantage of the ability to use variables with bracket notation.

In line 7, set aProperty to a string of the first property in james (ie. the job property).

Then print james's job using bracket notation and aProperty.


#2

Can you please provide a link to the exact exercise?


#3

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


#4

can you help me nicoekkart?


#5

The instructions are a bit unclear, you should set aProperty equal to the string "job" and then use that to get the property.


#6

Oops, try again. Do you have the variable 'aProperty' between brackets?


#7

Can you show your current code please?


#8

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"
console.log(aProperty);


#9

You should use the variable aProperty to get the property in james with this name.


#10

how must I do it?
please send code


#11

That would be boring, wouldn't it :smiley:.
In the code you had at first, you actually printed the correct thing. The problem was that aProperty was set wrongly.


#12

I would understand you if I was American,
I can not understand English very well. for that i please from you to send code,


#13

I'm sorry, but that's not the point of this forum. I'll guide you through it:
This is your current code

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"
console.log(aProperty);

The only problem with this code is that it prints job, instead of programmer. Notice that "programmer" is the value in the james object corresponding with the key "job".

If you needed the "married" key, you would do it like this

james["married"]

But we don't want "married", we want "job", any idea how to do this? (by using aProperty)