JavaScript showing undefined while calling INHERITED METHOD

Viewed 15

JavaScript is showing UNDEFINED along with OUTPUT while trying to call an INHERITANCE method, Anyone knows why that is?

This is the code:

class Car {
  drive() {
    console.log(`I am driving ${this.model}`)
  }
}

class Polo extends Car {
  model = "Polo GTI"
  color = "red"
}

let polo = new Polo()

console.log(polo.drive())

Output:

I am driving Polo GTI
undefined
0 Answers
Related