Update some of the exercises
This commit is contained in:
17
examples/characters/src/person.js
Normal file
17
examples/characters/src/person.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import { v4 as id } from 'uuid';
|
||||
|
||||
export class Person {
|
||||
constructor(firstName, lastName) {
|
||||
if (!firstName || !lastName) {
|
||||
throw new Error('First name and last name are required');
|
||||
}
|
||||
|
||||
this.id = 'person-' + id();
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
get fullName() {
|
||||
return `${this.firstName} ${this.lastName}`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user