Skip to content

Instantly share code, notes, and snippets.

@jrgleason
Created November 9, 2014 22:43
Show Gist options
  • Save jrgleason/75addb71dba3df20f54b to your computer and use it in GitHub Desktop.
Save jrgleason/75addb71dba3df20f54b to your computer and use it in GitHub Desktop.
Step 1 for the
function Animal(name) {
this.legs = [];
this.name = name;
console.log("Running Constructor " + name);
}
Animal.prototype.sayHello = function() {
var message = "Hello my name is " + this.name + " and I have " + this.legs.length + " legs"
return message;
}
function Dog(name) {
this.legs.push("Right Front");
this.legs.push("Left Front");
this.legs.push("Right Hind");
this.legs.push("Left Hind");
}
Dog.prototype = new Animal();
function Bird(name) {
this.legs.push("Right");
this.legs.push("Left");
}
Bird.prototype = new Animal();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment