/*
* Programming Quiz: Building Classes and Subclasses (2-3)
*/
class Vehicle {
constructor(color = 'blue', wheels = 4, horn = 'beep beep') {
this.color = color;
this.wheels = wheels;
this.horn = horn;
}
honkHorn() {
console.log(this.horn);
}
}
// your code goes here
class Bicycle extends Vehicle {
constructor(color, wheels, horn){
super(Vehicle);
this.wheels = 2;
this.horn = 'honk honk';
this.color = 'blue';
}
}
const myVehicle = new Vehicle();
myVehicle.honkHorn(); // beep beep
const myBike = new Bicycle();
myBike.honkHorn(); // honk honk测试答案如下报错如下为什么说Cannot read property 'name' of undefined?
添加回答
举报
0/150
提交
取消