Lesson 2: Fun with Functions


#1

So I used the code below to add the speak function. "Hello" does print out in the box but the error still says that I did not log it to the console. I have tried refreshing but it is still the same. What am I doing wrong?

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


#2

Just remember in an Object that you separate methods by commas " , " rather than semi-colons " ; ". So just change the semi-colons into commas and hopefully that should fix the error :smiley:

If not then pay close attention to the instructions and follow them word for word. Sometimes the console is expecting an EXACT response to pass the lesson.


#3

console.log("Hello") :arrow_right: console.log("Hello!")

Notice the :exclamation:


#4

Thanks guys! Debugging has never been my strong point :stuck_out_tongue:


#5

I too was missing the "!"... Oh man I need more coffee