Penguins, Properties, and the Prototype error, can somebody help?


#1


https://www.codecademy.com/courses/objects-ii/3/5?curriculum_id=506324b3a7dffd00020bf661#


Can someone please assist? I've been stuck on this part for quite some time and just can't figure out what's wrong with my code. Every time I get this error:
Oops, try again. Make sure to log the number of legs emperor has!


function Penguin(name, numLegs) {
    this.name = name;
    this.numLegs = 2;
};
// create your Emperor class here and make it inherit from Penguin
function Emperor(name,numLegs) {
    this.name = name;
};
Emperor.prototype = new Penguin();
// create an "emperor" object and print the number of legs it has
var emperor = new Emperor("john");
console.log(emperor.numLegs);


#2

Take numLegs out of function Emperor

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


#3

I think it's bugged, I had the exact same code above and it said I wasn't constructing my Emporer class. Weird.


#4

@objectrunner26471

Have a close look at your =emperor=

Emporer


#5

Yeah, i think it was bugged, I wrote the same code at a later time and everything worked just fine.


#6

Nice spot! A mere test. Ha. On Wed, Aug 17, 2016 at 12:10 AM, Leon <
codecademy@discoursemail.com [codecademy@discoursemail.com] > wrote:
leonhard.wettengmx.n
[https://discuss.codecademy.com/users/leonhard.wettengmx.n]
August 16

@objectrunner26471 [https://discuss.codecademy.com/users/objectrunner26471]

HAVE A CLOSE LOOK AT YOUR =EMPEROR=

EMPORER

Visit Topic
[https://discuss.codecademy.com/t/penguins-properties-and-the-prototype-error-can-somebody-help/53971/4]
or reply to this email to respond.

IN REPLY TO
objectrunner26471 [https://discuss.codecademy.com/users/objectrunner26471]

August 16

I think it's bugged, I had the exact same code above and it said I wasn't
constructing my Emporer class. Weird.

Visit Topic
[https://discuss.codecademy.com/t/penguins-properties-and-the-prototype-error-can-somebody-help/53971/4]
or reply to this email to respond.

To unsubscribe from these emails, click here
[https://discuss.codecademy.com/email/unsubscribe/e70e91f639398176ec79681cd3d90e18d720ec447c83f9be4c055cb9067ae7e8]
.


#7

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