Lesson passes even though code does not function as expected

function Animal(param1,param2){

// method for var objectName = new animal(arg,arg);
    console.log("Hi, my name is "+param.name);

// animalClass object
    var penguin=new Animal("sqwakPaddleFlap", 2);


replacing my console.print line with console.log("Hi, my name is "+this.name); causes the lesson to fail and tell me that my functions fails to properly log the string to the console. However leaving it as it is the lesson passes me but the console prints an error telling me that param is undefined, instead of printing out the string I expected. What gives?


according to hoe you defined the sayName method here

it takes in one argument but in your call i see no argument passed


So I'm supposed to call:

I'm sorry, I seem to be having trouble following these lessons. Why would I have penguin.sayName("squawk");? Wouldn't that defeat the purpose of making a universal method which any animal could use to automatically say its own name?

Also, I tried what you said, and you were right, that got the string to print :smile:
But still not as expected... I tried penguin.sayName("squawk");
This is what the console returned: Hi, my name is undefined X.X


ohh i see now the error is here

should not be param.name but rather this.name

modify the method to this

    console.log("Hi, my name is "+this.name);

Now you can call it like this


I missed that


X.X lol I just figured it out myself. That was actually the first thing I tried.
I've seen reports on here where some people say they have to refresh the page before the program that screens user code functions properly. In my case (I'm discovering) I have to actually load the url in a fresh browser window or tab. Yeesh. I tell you though, spend twelve hours trying to get the wrong code to work after giving up on the right one only to discover the problem was a glitch --you don't actually end up absorbing the lesson...