Created
December 5, 2015 10:19
-
-
Save clive-bunting/c5bf3d1d9f7c32e06e2a to your computer and use it in GitHub Desktop.
Bonfire: Make a Person
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
| // Bonfire: Make a Person | |
| // Author: @clive-bunting | |
| // Challenge: http://www.freecodecamp.com/challenges/bonfire-make-a-person# | |
| // Learn to Code at Free Code Camp (www.freecodecamp.com) | |
| var Person = function(firstAndLast) { | |
| var firstName = firstAndLast.split(' ')[0]; | |
| var lastName = firstAndLast.split(' ')[1]; | |
| this.getFirstName = function() { | |
| return firstName; | |
| }; | |
| this.getLastName = function() { | |
| return lastName; | |
| }; | |
| this.getFullName = function() { | |
| var fullName = firstName.concat(' ').concat(lastName); | |
| console.log(fullName); | |
| return fullName; | |
| }; | |
| this.setFirstName = function(name) { | |
| firstName = name; | |
| }; | |
| this.setLastName = function(surname) { | |
| lastName = surname; | |
| }; | |
| this.setFullName = function(firstAndLast) { | |
| firstName = firstAndLast.split(' ')[0]; | |
| lastName = firstAndLast.split(' ')[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