Intro to Objects II: Who's in Your Bracket?


#1

Please help, I'm stuck and I can't figure out why.
The instructions are as follows:
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.

I keep getting an error "It looks like james' job was not logged to the console." when I run the following 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]);

#2

That begs the question, was it?

If yes, then you'd start looking for typos and such
if no, then it's the printing that needs fixing, and perhaps there's an error message from the interpreter


#3

I have attached the code. As you can see I have used console.log. Please help me figure out what I am doing wrong.


#4

Check if james job should be "programmer", maybe it should be capitalized or something.


#5

Yes I can see that. But was it printed? That's what it asks about so the first observation that's required to figure it out is whether it was printed, regardless of what the code is.

It says it wasn't, so verify whether that's the case.

If nothing was printed, if you have an error message in the console, then that is hugely relevant.


#6

With this code, nothing is getting printed. However the required string is getting printed if I remove 'console.log', but the same error is being shown in that case.


#7

So you're saying console.log does nothing? Sounds like you assigned a different function to that name. Refresh page.

// console.log will now do nothing
console.log = function() {};

#8

I refreshed the browser and the same code worked perfectly this time! Guess it was not a problem with the code after all. Thank you so much for your help!:relieved: