Skip to content

Instantly share code, notes, and snippets.

@NormanBenbrahim
Created April 18, 2016 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NormanBenbrahim/94b66dedeb00e87dc2ab1719ae0c2dc9 to your computer and use it in GitHub Desktop.
Save NormanBenbrahim/94b66dedeb00e87dc2ab1719ae0c2dc9 to your computer and use it in GitHub Desktop.
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