Skip to content

Instantly share code, notes, and snippets.

@khalid32
Last active June 1, 2017 03:58
Show Gist options
  • Save khalid32/86d038ec2a9bcb048d9be34c10db405c to your computer and use it in GitHub Desktop.
Save khalid32/86d038ec2a9bcb048d9be34c10db405c to your computer and use it in GitHub Desktop.
Freecodecamp's Advanced Algorithm Scripting Challenge
var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
this.first = firstAndLast.split(' ')[0];
this.last = firstAndLast.split(' ')[1];
this.getFirstName = function(){
return this.first;
};
this.getLastName = function(){
return this.last;
};
this.getFullName = function(){
return this.first + ' ' + this.last;
};
this.setFirstName = function(str){
this.first = str;
};
this.setLastName = function(str){
this.last = str;
};
this.setFullName = function(str){
this.first = str.split(' ')[0];
this.last = str.split(' ')[1];
};
};
var bob = new Person('Bob Ross');
bob.getFullName();
Object.defineProperty(bob, 'first', {
enumerable: false,
});
Object.defineProperty(bob, 'last', {
enumerable: false,
});
var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
var first = firstAndLast.split(' ')[0];
var last = firstAndLast.split(' ')[1];
this.getFirstName = function(){
return first;
};
this.getLastName = function(){
return last;
};
this.getFullName = function(){
return first + ' ' + last;
};
this.setFirstName = function(str){
first = str;
};
this.setLastName = function(str){
last = str;
};
this.setFullName = function(str){
first = str.split(' ')[0];
last = str.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