関数feedAmountをコンソールに出力しようとしていますが、行き詰まります。誰かが私をまっすぐにするのを手伝ってくれる(そして必要ならこれを最適化する)ことができますか?追加の質問として、プロトタイプを作成できますか?Chicken.prototype.chickenFeed( "small")?ありがとう!
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);
}
}