It all about Genes (What did I do wrong?)


#1

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

it says that I have not added a name, but I think I have so I don't know what Im doing wrong.

// create your Animal class here
function Animal(name, numLegs) {
    this.name = name;
    this.numLegs = numLegs;
    }


// create the sayName method for Animal

Animal.prototype.sayName = function() {
    console.log ("hello my name is " + name)
    
    }



// provided code to test above constructor and method
var penguin = new Animal("Captain Cook", 2);
penguin.sayName();

#3

put a semicolon( ; ) at the end of the animal class.. and try this...

Animal.prototype.sayName = function(){
console.log("Hi my name is " + "" + this.name);
};

worked for me!


#4

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