<html>
<body>
<h2>JavaScript Class Method</h2>
<p>Pass a parameter into the "present()" method.</p>
<p id="demo"></p>
<script>
class Car {
constructor(brand) {
this.carname = brand;
}
present(x) {
return x + ", I have a " + this.carname;
}
}
mycar = new Car("Ford");
document.getElementById("demo").innerHTML = mycar.present("Hello");
</script>
</body>
<!-- Mirrored from www.w3schools.com/js/tryit.asp?filename=tryjs_classes_method2 by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 02:39:34 GMT -->
</html>