How Do I Do This?


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


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


Assuming you understand all of the earlier content on Objects, their properties, etc. A method is a function in the scope of an object, and is called by object notation. As you can see, the speak() method is being called on it's object, user.

To construct this method isn't very special, it's the same as a normal property, however you're not simply assining a method, you're doing so within a constructor, so you would continue using this keyword as you have been.

this.speak = function (parameter) {};

Also remember that when declaring properties in an object, you would separate the lines with a comma, however you're using a function to construct an object, this is why you're using semicolons here, because it's just a function.

Now the return you want is probably a console.log, or something like that, so I will let you fill in the rest yourself, just remember to pass the parameter along within your method whatever you do, so that you can type anything you want into it.

user.speak('I am speaking this through a parameter being passed through this function and returned somewhere');