This site is mobile accessible. Press the "Tap Here" button to use a smaller font-size.
Smartphone icons created by Freepik - Flaticon
Pass a parameter into the "age()" method.
class Car { constructor(name, year) { this.name = name; this.year = year; } age(x) { return x - this.year; } } const date = new Date(); let year = date.getFullYear(); const myCar = new Car("Ford", 2014); document.getElementById("demo").innerHTML= "My car is " + myCar.age(year) + " years old.";