It's All in the Genes


#1

I've searched and searched and I cannot figure out why I'm getting the error "SyntaxError: Unexpected token {"
Can anyone help?


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

// create the sayName method for Animal
Animal.prototype.sayName(){
    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

Ah finally figured it out, was missing the "function" after "Animal.prototype.sayName".

Never mind.