I have a problem in my code


#1

Hello!

I have a problem in my code.

can anyone help me??

https://www.codecademy.com/en/courses/objects-ii/3/1

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

// create the sayName method for Animal
Animal.prototype.sayName = function(){
console.log("Hi my name is: " + this.name);
};

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


16, Its all in the genes
#2

It looks like you have some Python, C or Java in your lexicon. However, the term class is a misnomer in ES5. It is the term we use to describe a function that acts as a model or template of an object class. I know this is confusing, but just go along with it, for now.

Change,

class Animal

to

function Animal

#3

Thanks :slight_smile:

Already it works !!! :grin: