Submission Status: Passed
Submitted for: Guide to JavaScript OOP Instance Methods
Submitted at: February 23, 2023
class Car { constructor({ year, brand, poweredBy = 'gas' }) { this.year = year; this.brand = brand; this.poweredBy = poweredBy; } carSpecs() { return(`The ${this.year} ${this.brand} runs on ${this.poweredBy}`) } } const model3 = new Car({ year: 2023, brand: "Tesla", poweredBy: "electricity" }); console.log(model3.carSpecs());
devCamp does not support ancient browsers.
Install a modern version for best experience.