Exercies 20 - emperor penguins


#1

i'm not seeing my syntax error.
"Make sure to log the number of legs emperor has!"

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 ("fred");
console.log(emperor.numLegs);


#3

In this, you have to use

Emperor.prototype = new Penguin();

to solve this level, as shown in the directions and hint.

You do not make a function in this level, as you have done here:

I believe you should take that out, if it still doesn't work, refresh.


#4

It works fine for me


#5

:smiley: yea i agree with u


#6

your code should look like this
The console wants you to change the name of "Emperor"
to another object Name of preference. Your code is very valid its just the console setup.
Try and see if it works for you.

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

function Emperor(name){
this.name = name;
};
Emperor.prototype = new Penguin();

var Scoth = new Emperor("Drakonia");
console.log(Scoth.numLegs);


#7

I logged out and back in and it started to work, so it may have just needed a refresh.
Thank you for all the help!
I'm now wrestling with JQuery - yahoo.


#8

Yeahh..! Thanks dear.. After 8 times it passed me..