21 lines
439 B
JavaScript
21 lines
439 B
JavaScript
class Student{
|
|
constructor(firstName, lastName, age)
|
|
{
|
|
this.firstName = firstName;
|
|
this.lastName = lastName;
|
|
this.age = age;
|
|
}
|
|
|
|
greeting() {
|
|
console.log(`Hi, my name is ${this.firstName} ${this.lastName}. I'm ${this.age} years old.`);
|
|
|
|
};
|
|
};
|
|
|
|
const jonny = new Student("Jonny", "Hilbert", 22);
|
|
const lisa = new Student("Lisa", "Lauser", 41);
|
|
|
|
|
|
|
|
jonny.greeting();
|
|
lisa.greeting(); |