Penguins, Properties, and the Prototype


#1


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


I followed the instructions as I learned them and believe "I am right" I don't understand why the console doesn't log how many number of legs it emperor has. Maybe I've overlooked the bug but I can't quite find out why it is not an acceptable answer.

My error code, "Oops, try again. 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("Midas");
console.log(emperor.numLegs);


#2

@irvgonz,
Your code looks ok...
++++ 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

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