Exercise 4.4


#1

why will this only pass me if I use a lower case penguin see below.
var penguin = new Penguin("Bob"); vs var Penguin = new Penguin("Bob");

// 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("Bob");
penguin.sayName();


#2

It will only work if you put the variable lower-cased because you already put Penguin as a function AND a prototype for it:

Therefore, if you put the variable capitalized, it would make those two things function.


#3

Thank you for the help.