Introduction to Objectsii 2/30


#1

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

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

Add a speak method to the Person constructor. Whenever speak is called, it should print "Hello!" to the console.


#2

So, you are yet to "log" your new method. A clue is to do:

object.method();

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.