需要指导如何编写三个实例,然后使用isWarmBlooded方法为变量赋值。
```Animal.prototype.isWarmBlooded = function(species){
if(this.species === "Fish"){
return this.species = false;
}
if(this.species === "Monkey" || this.species === "Bird"){
return this.species = true;
}
if(this.species !== "Fish" || this.species !== "Monkey" || this.species !== "Bird"){
return "Could not determine if warm-blooded";
}
};
//Call the isWarmBlooded method on three Animal instances
//and assign the values to each variable below.
var warmBloodedAnimal = Animal.prototype.isWarmBlooded("Monkey");
var coldBloodedAnimal;
var notWarmOrColdAnimal;```
答案 0 :(得分:0)
var Animal = function (species){
this.species = species;
};
Animal.prototype.isWarmBlooded = function(species){
if (this.species === "Fish"){
return false;
}
else if(this.species === "Monkey" || this.species === "Bird"){
return true;
}
else{
return "Could not determine if warm-blooded";
}
};
var warmBloodedAnimal = new Animal("Monkey");
console.log(warmBloodedAnimal.isWarmBlooded());