본문 바로가기

salesforce certification

(4/60) Refer to following code: class Vehicle {constructor(plate) { this.plate =plate; }}Class Truck extends Vehicle {constructor(plate, weight) { //Missing code this.weight = weight; }displayWeight() { console.log('The truck ${..

Refer to following code:

class Vehicle {
constructor(plate) {
       this.plate =plate;
    }
}
class Truck extends Vehicle {
constructor(plate, weight) {
    //Missing code
    this.weight = weight;
    }
displayWeight() {
        console.log('The truck ${this.plate} has a weight of ${this.weight} lb.');
    }
}
let myTruck = new Truck('123AB', 5000);
myTruck.displayWeight();

Which statement should be added to line 09 for the code to display 'The truck 123AB has a
weight of 5000lb.'?

 

javascript ES6에서 추가된 class 문법