Created
April 18, 2016 18:28
-
-
Save NormanBenbrahim/94b66dedeb00e87dc2ab1719ae0c2dc9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 full_arr = firstAndLast.split(' '); | |
var firstName = full_arr[0]; | |
var lastName = full_arr[0]; | |
var fullName = firstName + ' ' + lastName; | |
// now build the methods | |
function getFirstName() { | |
return firstName; | |
} | |
function getLastName() { | |
return lastName; | |
} | |
function getFullName() { | |
return firstAndLast; | |
} | |
function setFirstName(first) { | |
firstName = first; | |
} | |
function setLastName(last) { | |
lastName = last; | |
} | |
function setFullName(firstAndLast) { | |
fullName = firstAndLast; | |
} | |
}; | |
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