16/30. What is the error here?


#1

i get error SyntaxError: missing before statement. Can you please explain to me where is the error in my code?

// create your Animal class here
var Animal = function(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();

#2

Please format your post as I have done (select entire code block; press Ctrl+Shift+C) from next time. Thanks! :smile:

Hint: You are using colons instead of the = sign on lines 3 and 4.

Note that we use colons in object literal syntax:

var obj = {
    prop1: "val1"
};

and in function constructors we have statements which must have equal sign for assigning values.


#3

figured it out,thanks anyway:)