function ftalk(kindOfPet) { if(kindOfPet == "dog") { document.writeln("bow-wow!"); } else { if(kindOfPet == "cat") { document.writeln("meow-meow-meow"); } } } function pet(inputName, inputKind, inputColor) { this.name = inputName; this.kind = inputKind; this.color = inputColor; this.talk = ftalk(inputkind); } var Boots = new pet("Boots", "cat", "orange striped"); Boots.talk;
function pet(inputName, inputKind, inputColor) { this.name = inputName; this.kind = inputKind; this.color = inputColor; this.talk = ftalk(inputKind); // 此处 inputkind 的 k 改为大写, 要仔细 - - }