class Animal {
constructor(name) { this.name = name; }
speak() { return this.name + ' makes a sound.'; }
}
const dog = new Animal('Rex');
dog.speak(); // 'Rex makes a sound.'Classes group related state (properties) and behavior (methods) under one blueprint.
ES6 introduced the class keyword, which is syntactic sugar over JavaScript's prototype-based model. A class can have a constructor method that runs when you create an instance, and methods that become part of the prototype.
Challenge: Create a class with a constructor and a method that returns a formatted string.