Skip to content

Instantly share code, notes, and snippets.

@nickihastings
Created April 16, 2018 18:29
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save nickihastings/8fd63b3389d4e119423ba0313cdfc316 to your computer and use it in GitHub Desktop.
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');
bob.getFullName();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment