#20 Works fine but receives an Error message


#1

My solution works as it should however it receives an error that says

// Make sure to properly define the Emperor constructor!

This is my solution...

function Penguin(name) {
this.name = name;
this.numLegs = 2;
}

// create your Emperor class here and make it inherit from Penguin
function Emperor(name)
{
this.name = name;
};

Emperor.prototype = new Penguin();

// create an "emperor" object and print the number of legs it has
var Emperor = new Emperor(name)
{
this.name = "Mister"
this.numLegs = 2;
};
console.log(Emperor.numLegs);


#2

should be,

var emperor = new Emperor("Mister");
console.log(emperor.numLegs);

#3

My new solution looks like this however I still get an error saying

(Make sure to properly define the Emperor constructor!)

function Penguin(name) {
this.name = name;
this.numLegs = 2;
}

// create your Emperor class here and make it inherit from Penguin
function Emperor(name)
{
this.name = name;
};

Emperor.prototype = new Penguin();

// create an "emperor" object and print the number of legs it has
var Emperor = new Emperor("Mister");
console.log(Emperor.numLegs);


#4

The letter case is critical. We cannot declare an instance of a class and give it the same name as the constructor. Use lower case in instance variable names and this will never happen.

    var emperor = new Emperor("Mister");

#5

This is a working solution. Thank you @mtf

function Penguin(name) {
this.name = name;
this.numLegs = 2;
}

// create your Emperor class here and make it inherit from Penguin
function Emperor(name)
{
this.name = name;
};

Emperor.prototype = new Penguin();

// create an "emperor" object and print the number of legs it has
var emperor = new Emperor("Mister");
console.log(emperor.numLegs);