Penguins, Properties, and the Prototype


#1

I couldn't find any mistakes in my code as bellow in terms of showing the number of legs, I also checked out someone's post that was the same as the problem, but I can't still figure out any errors from my code. Does anyone suggest ? Thanks :smile:

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

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

// create your Emperor class here and make it inherit from Penguin
Emperor.prototype = new Penguin();

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

//console.log(emperor.numLegs);
console.log(legs);

ERROR: Oops, try again. Make sure to log the number of legs emperor has!


#2

@dickychiang,

Your code is correct....
Maybe
++++ reset of session *****************
As you are manipulating with objects
under certain circumstances you can shoot your Browser in an
inconsistent state.

Therefor it is of an advantage to know that you have 2 reset facilities:

One is the use of the F5-key which does a refresh Browser

and

Two, select&copy your code
Then use the Reset Code button of the course-window,
then paste your code back in.

Addendum
General Notes:
Always refresh the browser after making corrections:
CTRL f5 ( if on Windows or Linux)
CMD r ( if on a MAC).
CTRL 0 to reset browser zoom


#3

You're right, just refreshing my broswer, thanks