I’m doing the Make a Person challenge and just can’t debug my solution and understand where I’m going wrong. After some exhausting hours, I decided to check the spoiler alert I see its similar but they put the splitting of the full name in both the set and get methods. Why can’t I not have it as a local variable?
Here is my code:
function Person(firstAndLast) {
this.sFullName = firstAndLast;
var aNames = firstAndLast.split(' ');
this.sFirstName = aNames[0];
this.sLastName = aNames[1];
// Setters
this.setFirstName = function(sFirstName){
this.sFirstName = sFirstName;
};
this.setLastName = function(sLastName){
this.sLastName = sLastName;
};
this.setFullName = function(sFullName){
this.sFullName = sFullName;
};
// Getters
this.getFirstName = function() {
return this.sFirstName;
};
this.getLastName = function() {
return this.sLastName;
};
this.getFullName = function() {
return this.sFullName;
};
}
var bob = new Person('Bob Ross');