Penguins, Properties, and the Prototype


#1

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

I keep getting the following error: Oops, try again. 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 Emporer(name) {
    this.name = name;
}

Emporer.prototype = new Penguin();

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


#2

@itschrisburton,
Have you tried a refresh Browser

++++ 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

I have. I tried doing that twice without success.


#4

OMFG I spelled Emperor as Emporer. Wasting 30 minutes of my life.


#5

yep about 30 min for exact same spelling error too...


#7

var emperor = new Emperor("jason");

emperor.numLeg = function() {
console.log(this.numLegs);
};

emperor.numLeg();
try this it worked for me


#8

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