Lesson 5 who is in brackets


#1

this is simply my code
var james = {
job: "programmer",
married: false
};
var aProperty = james['job'];
console.log(aProperty);

it prints out "programmer"as instructed
butr saying did u put aProperty in brackets?

y?

i cant believe such a short (3 lins ) code making all thistrouble for me
what about big programs? :persevere::cry:


#2

First off, you set jame's job incorrectly. You should set aProperty to the string job. Like so:

var aProperty = 'job';

And then, It wants you to make use of arrays, so in console.log they want you to log aProperty from the array james. Like this:

console.log(james[aProperty]);

#3

yes you r right

thnak u very much


#4

It didnt work for me. Here's my 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(james[aProperty]);

and it says that james' job was not logged into the console


#5

Having the same issue, code matches yours, and no good. If I eliminate the console.log and just have james[aProperty] on the right I see "programmer"...


#6

I just refreshed the page and resubmitted and all is well in the world. Very strange...


#7

Good on you for saying. xD


#8

Thanks for the advice to refresh the page
couldn't understand what the ■■■■ is happening for 20 minutes, gosh :joy:


#9

Thank u so much...!!


#10

My output is "undefined".
Question 1: why would I be referencing an array when james is an object, not an array?
Question 2: why do I need to use james[aProperty]) in my console log when I am not printing from the object james but from a variable outside of the object?

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]);