algorithms/makePerson.js
2024-01-12 07:01:06 -05:00

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());