make-a-person
- [Intermediate Algorithm Scripting: Make a Person | freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/make-a-person)
- [freeCodeCamp Challenge Guide: Make a Person - Guide - The freeCodeCamp Forum](https://forum.freecodecamp.org/t/freecodecamp-challenge-guide-make-a-person/16020)
答案
```js const Person = function (firstAndLast) { // Only change code below this line let fullName = firstAndLast this.getFirstName = function () { return fullName.split(' ')[0] } this.getLastName = function () { return fullName.split(' ')[1] } this.getFullName = function () { return fullName }
this.setFirstName = function (name) { fullName = name + ' ' + fullName.split(' ')[1] } this.setLastName = function (name) { fullName = fullName.split(' ')[0] + ' ' + name } this.setFullName = function (name) { fullName = name } }
const bob = new Person('Bob Ross') bob.getFullName() ```