Just completed the “Make a Person” challenge. My code:
var Person = function(firstAndLast) {
// Only change code below this line
// Complete the method below and implement the others similarly
var nameArr = firstAndLast.split(" ");
this.getFirstName = function() {
return nameArr[0];
};
this.getLastName = function() {
return nameArr[1];
};
this.getFullName = function() {
return nameArr.join(" ");
}
this.setFirstName = function(firstInput) {
nameArr[0] = firstInput;
}
this.setLastName = function(secInput) {
nameArr[1] = secInput;
}
this.setFullName = function(fullInput) {
nameArr = fullInput.split(" ");
}
return firstAndLast;
};
I’m still a bit uncomfortable with objects. Requesting any feedback or advice on the way I solved this. Thanks.