Search⌘ K
AI Features

Challenge: ES6 Inheritance

Explore ES6 inheritance by creating Vehicle and Car classes where Car inherits from Vehicle. Learn to customize constructors and methods such as turnOn and turnOff based on fuel levels and parking status. This challenge helps solidify object-oriented programming concepts in JavaScript through hands-on practice.

Problem statement

In this challenge, there are two classes, Vehicle and Car. You need to implement inheritance between them so that Car is the child class and Vehicle is the parent. You have the following tasks:

  • Define a constructor for Vehicle that initializes a fuel (given in ml) property.

  • Define the turnOn and turnOff functions in ...