Created
April 16, 2018 18:29
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 …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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