2. Fun with functions - URGENT!


#1


https://www.codecademy.com/courses/objects-ii/0/2?curriculum_id=506324b3a7dffd00020bf661


I think I got all the codes correct in here (as I have went through the Q&A in this forum section as well). However, the system still doesn't let me pass? Can anyone help me for that? Thanks!


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

Yeah your code looks fine to me,

Try refreshing the page or reset code and paste in again


#3

speak needs to be added as a parameter.


#4

I don't see anything wrong. What was the error message?


#5

I'm not sure about using speak as a parameter, because I passed using jim_prince's code.


#6

Take off the semicolon at the end of the first curvy bracket :).


#7

His code actually works with and without said semicolon on my end... so strange that it isn't working :confused: I completed the lesson with the same exact code days ago.

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


#8

Actually, that isn't true. The function does not request for a parameter:

this.speak = function(){

Therefore, none should be passed.

user.speak();


#9

Odd, maybe this course is just buggy then? Because I've passed a lesson and the code was completely wrong lol.


#10

Try clearing the cache and restarting the browser. If the problem persists try a different browser and see if the code works.


#11

Probably. I noticed I have to do what @zainabrawat recommended on a lot of the PHP exercises.


#12

Thanks everyone. I tried to restart my laptop and finally got the section passed with the code listed above. Perhaps there is a bug somewhere in this page.

Anyway. Thanks!!


#13

I had the same issue because I was printing "Hello" w/o "!". Try adding exclamation point.


#14

I had the same problem and simply refreshed the page. Worked following the refresh.


#15

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