It seems to work?!?


#1


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


The console says: "Hi my name is Captain Cook

Code academy says: Oops, try again. It looks like your Penguin constructor doesn't properly take in two parameters and save them as this.name and this.numLegs respectively


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


// create a Penguin constructor here
function Penguin(name, numLegs) {
    this.name = name;
    this.numlegs = numLegs;
};

// create a sayName method for Penguins here
Penguin.prototype.sayName = function() {
    console.log("Hi my name is " + this.name);
};

// our test code
var theCaptain = new Penguin("Captain Cook", 2);
theCaptain.sayName();


#2

I repeated exactly what I did with the Animal class and it only complains about the Penguin Class


#3

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

// create a Penguin constructor here
function Penguin(name,numLegs) {
this.name = name;
this.numLegs = numLegs;
};

// create a sayName method for Penguins here
Penguin.prototype.sayName = function() {
console.log("Hi my name is " +this.name);
};

// our test code
var theCaptain = new Penguin("Captain Cook", 2);
theCaptain.sayName();

This is my code
The only thing we don't have in common is that ; when your function Animal ends


#4

Your's actually worked?!?


#5

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