I am trying to get the function feedAmount to print to the console but am getting stuck. Can someone help straighten me out (and optimize this if it needs to be)? As an added question, could I prototype? chicken.prototype.chickenFeed(“small”)? Thanks!
var chicken = new chickenObj("cluck");
chicken.talk();
function chickenObj(says) {
this.says = says;
this.talk = function talk() {
console.log("::" + this.says);
}
}
chicken.chickenFeed = new chickenFeed("small");
chicken.chickenFeed.foodAmount();
function chickenFeed(size) {
this.size = size;
function foodAmount() {
if(this.size === "small") {
this.food = "1 pound of feed";
} else if(this.size === "medium") {
this.food = "2 pound of feed";
} else if(this.size === "large") {
this.food = "3 pound of feed";
}
console.log(this.food);
}
}
And while you are at it put the
.talktochickenObj.prototypeas well.