Keeps Saying 'TypeError: Object Expected'!


#1


This error just keeps appearing, not really sure what is wrong here, just know it will be a very small error :joy: ...some help identifying it please?


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

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


#2

HI these lines

    this.speak = console.log("Hello!");
    // add a "speak" method to Person!

they aske you to create a method speak


#3

you have to add method like

this.someMethod = function() {

  };

so there

this.speak=function(){
    console.log("Hello!");
}

#4

Ah OK, I thought it may be what you have said rcodeman, but did not know how to incorporate it and structure it correctly. Thanks a lot to both of you, it now works with the changed function!


#5

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