Created
December 21, 2015 21:36
-
-
Save Narshe1412/952280800c5caafe073e to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/narshe1412 's solution for Make a Person
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) { | |
//this.fullName = firstAndLast; | |
var fullName = firstAndLast; | |
var splitName = fullName.split(" "); | |
var first = splitName[0]; | |
var last = splitName[1]; | |
this.getFirstName = function (){ | |
//return first; | |
return fullName.split(" ")[0]; | |
}; | |
this.getLastName = function(){ | |
return fullName.split(" ")[1]; | |
}; | |
this.getFullName = function(){ | |
return fullName; | |
}; | |
this.setFirstName = function(val){ | |
fullName = val + ' ' + last; | |
}; | |
this.setLastName = function(val){ | |
fullName = first + ' ' + val; | |
}; | |
this.setFullName = function(val){ | |
fullName = val; | |
}; | |
}; | |
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
https://app.pluralsight.com/training/player?course=javascript-objects-prototypes&author=jim-cooper&name=javascript-objects-prototypes-m2&clip=0&mode=live