19/30 Why is not printing?


#1

This is my code:

// the original Animal class and sayName method
function Animal(name, numLegs) {
    this.name = name;
    this.numLegs = numLegs;
}
Animal.prototype.sayName = function() {
    console.log("Hi my name is " + this.name);
};

// define a Penguin class
function Penguin(name) {
    this.name = name;
    this.numLegs = 2;
};

// set its prototype to be a new instance of Animal
Penguin.prototype = new Animal ();
var penguin = new Penguin ("Happy Feet");
penguin.sayName();

The code passes, but nothing is printed. I have already looked for mistakes, but I didn't realized what I got wrong. Can anyone help me?


#2

It seems like just an error with the site or something, it prints fine if I run it, so try refreshing.


#3

Maybe you should put a semicolon and number 2 in parenthesis, like this

var penguin = new Penguin ("Happy Feet", 2);

Try


#4

function Animal(name, numLegs) {
this.name = name;
this.numLegs = numLegs;
}
Animal.prototype.sayName = function() {
console.log("Hi my name is " + this.name);
};

// define a Penguin class
function Penguin(name) {
this.name = name;
this.numLegs = 2;
};

// set its prototype to be a new instance of Animal
Penguin.prototype = new Animal();

// Here's where I need to create the Penguin object
var penguin = {
name: "Pinguino"

};
var penguin = new Penguin("Pinguino");
penguin.sayName();


#5

It seems like the codecademy reader is buggy... I use Google Chrome and to see what the code should print I copy it, press F12, go to Console, paste the code and press Enter. You can also do it easily if you use Chrome. (I don't know how about other browsers though)