Lesson 2 Fun With Functions


#1

this is my code:

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

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

why isn't it working?
Thnx


#2

Hey @hellopopit! You dont have a code error, but your problem is that the function name should be speak instead of speakMethod(as you did below)

Hope this helped! If it didnt pls reply saying so!


#3

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


#4

Hey guys thank you for helping me out.


#5

ya your code works......