Classes
โ Report an issue with this lessonclass Course {
constructor(title, price) {
this.title = title;
this.price = price;
}
describe() {
return `${this.title} -- $${this.price}`;
}
}
class MasteryCourse extends Course {
describe() {
return `${super.describe()} (Mastery)`;
}
}
JS classes are largely syntax sugar over its prototype-based object system, but they read the same as classes in Java or Python, which is why most modern JS is written this way rather than with raw prototypes.
Try it yourself
Exercise: Create a MasteryCourse class extending Course that overrides describe() to add ' (Mastery)'.
Expected output:
Rust Mastery -- $149.99 (Mastery)
Run your code and get it working before marking this lesson complete.
// that was the last free lesson
9 more lessons โ including Capstone project: a small app with state โ plus a certificate are waiting.
Unlock the full course โ $149.99