title: Classes and constructor in Es6 program
body: <p>Create a class car with a constructor function which accepts 2 parameters (name and distance). Include a prototype method in class, which returns a message(msg) "car name(name) had travelled for distance(distance) miles".</p>
  
  <p>I know its a very simple question, but I guess I am not able to design the code well, though it is giving me the right result yet I believe as per standards it is not right??</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>class Car {
    constructor(name, distance) {
      this.name = name;
      this.distance = distance;
  
    }
    lengthMiles() {
      console.log(`${this.name} had travelled for ${this.distance} miles`)
    }
  }
  
  var msg = new Car('Audi', 100);
  msg.lengthMiles();</code></pre>
  </div>
  </div>
  </p>