root@coding-prodigies:~# โ–Š
// lesson 3 of 12 ยท 16 min

Classes

โš‘ Report an issue with this lesson
class 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)
javascript
Output

      
    

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