Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Fill in the object constructor with the following methods below: getFirstName() getLastName() getFullName() setFirstName(first) setLastName(last) setFullName(firstAndLast) Run the tests to see the expected output for each method. The methods that take an argument must accept only one argument and it has to be a string. These methods must be the …
var Person = function(firstAndLast) {
var arr = firstAndLast.split(' ');
var firstName = arr[0];
var lastName = arr[1];
// Complete the method below and implement the others similarly
this.getFullName = function() {
return firstName + ' ' + lastName;
this.getFirstName = function() {
return firstName;
this.getLastName = function() {
return lastName;
this.setFirstName = function(first){
firstName = first;
this.setLastName = function(last){
lastName = last;
this.setFullName = function(firstAndLast){
var arr = firstAndLast.split(' ');
firstName = arr[0];
lastName = arr[1];
var bob = new Person('Bob Ross');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment