Object || lesson 2 fun with functions


please help

function Person(job, married) {
this.job = job;
this.married = married;
// add a "speak" method to Person!
this.speak = function(){

var user = new Person("Codecademy Student",false);

error: Oops, try again. It looks like 'Hello!' wasn't logged to the console. Make sure that you properly defined the method and that you didn't change any of the provided code.


You printed "hello" instead of "Hello!". Slight mistake there :smiley:


Thank u very much.


and whats wrong with this code plz

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"


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


You put this as a string:

Because it's a key/property of james, you aren't supposed to put "job", but just job.:smiley:


i thought so too

but it doesnt even work with both ways


Okay, first, I found out this is lesson 5, not lesson 2. Second of all, you did a little flaw over there, now that I see what you're supposed to do. The problem is that you're printing


Which is a problem. What you're supposed to do is name aProperty as "job".

var aProperty = "job"

Now, you can't just print aProperty, for that'll just print "job". So you have to say that it's the property of james, like this:


Hope it helped!:smiley:


perfect answer and explanation

thanks a lot