class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
sayName() {
alert(this.name);
}
}
// Create three instances of the Person class with some made-up data
const p1 = new Person('Alice', 25);
const p2 = new Person('Bob', 30);
const p3 = new Person('Charlie', 28);
// The method `sayName` has been added to the Person class using ES6 syntax.
I'm still learning JavaScript and figuring out how to work with classes. I find it easier to add new properties than new functions to a class. Practice makes perfect!