Lesson 2 Fun With Functions

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

That’s what alert says:
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.

I didn’t get what is wrong with my code.

@designpro95498,

Maybe…

++++ reset of session *****************
As you are manipulating with objects
under certain circumstances you can shoot your Browser in an
inconsistent state.

Therefor it is of an advantage to know that you have 2 reset facilities:

One is the use of the F5-key which does a refresh Browser

and

Two, select&copy your code
Then use the Reset Code button of the course-window,
then paste your code back in.

Addendum
General Notes:
Always refresh the browser after making corrections:
CTRL f5 ( if on Windows or Linux)
CMD r ( if on a MAC).
CTRL 0 to reset browser zoom

3 Likes

ANGRY!!! Angry !!! Angry !!! !!! i can’t got - why my ### code dont working !!!

@cm90,
If you could display the code you are using
mentioning the Oops- or Error message you are getting ???

It looks like it didnt run because you have one of your last semi colons in the wrong place. This code worked for me.

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

I have a similar code, that i get error message for:

function Person(job, married) {
this.job = job;
this.married = married;
}

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

};

var user = new Person(“Codecademy Student”,false);
this.speak();

error message: Oops, try again. Make sure you added a speak method to the Person constructor

because your speak function should be within the person function. Right now it is associated by itself rather than within the person function which is why you have the error

you did not add speak to the person function

refreshing worked for me! Thanks