28 lines
No EOL
799 B
JavaScript
28 lines
No EOL
799 B
JavaScript
class Person {
|
|
constructor(firstAndLast) {
|
|
let fullName = firstAndLast;
|
|
|
|
this.getFullName = function () {
|
|
return fullName;
|
|
};
|
|
this.getFirstName = function () {
|
|
return fullName.split(' ')[0];
|
|
};
|
|
this.getLastName = function () {
|
|
return fullName.split(' ')[1];
|
|
};
|
|
this.setFirstName = function (name) {
|
|
return fullName = name + ' ' + this.getLastName();
|
|
};
|
|
this.setLastName = function (name) {
|
|
return fullName = this.getFirstName() + ' ' + name;
|
|
};
|
|
this.setFullName = function (name) {
|
|
return fullName = name;
|
|
};
|
|
// return firstAndLast;
|
|
}
|
|
}
|
|
|
|
const bob = new Person('Bob Ross');
|
|
console.log(bob.getFullName()); |