Its All in the Genes: Unexpected token {


I've been trying to figure out the problem here, but for the life of me I can't find it. I keep getting the error " SyntaxError: Unexpected token {" Any help would be much appreciated. Thanks!

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

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

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


check the hint:

Return to the previous lesson for help on creating your own classes. Remember how we created a Person class

How you create your own class, is not what your learned


You have wrong syntax for Animal constructor. should be:

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

new Object() is using for creating object but not for creating a constructor:

var obj = new Object(); = "myObj";


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