5. Whos in your bracket ? need help


#1



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


Replace this line with your code. 
var james = {
    job: "programmer",
    married: false
};

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

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


#2

Remove the james[aProperty]; after var aProperty = "job";

You don't have to set the property since it uses the one used in the object ("job" property in this case).


#3

this comment:

// set to the first property name of "james"

is trying to tell you declare a variable called aProperty, which will hold the of value first property. the first property is job, so to get james job do james['job']

does that make sense?


#4

Using james["job"] at that point is the same thing as not using it, because it's first property is job: "programmer", and it is unchanged.Therefore the use of james["job"] in that case is not necessary, because it does nothing.

You might want to use that if you want to specify another value for the job property.For example:
james["job"] = "doctor";

or if you want to console log it.:
console.log(james["job"]);


#5

i seem to have a slightly alternative solution in the editor. Let me correct it, this is right:

var aProperty = "job";

it matches instructions:

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

then this step:

Then print james's job using bracket notation and aProperty

which he does here:

james[aProperty];

except this should be logged to the console:

console.log(james[aProperty]);

and then this line:

console.log(aProperty);

can be removed, then you have done it exactly as asked by the instructions, but there are multiply way to solve this problem


#6

Of course, there are many methods to solve this, but according to the instructions, for the console log you have to use the brackets and the aProperty. This way the user practices what he recently learned.


#7

i dont know about other methods, but i really understood your explanation, thank you :slight_smile:


#8