`Tell us what’s happening:
I pass the first 6 tests but I am pretty sure I am doing it the wrong way. To pass the get first name I am just returning the argument
To pass the get first name and get last name I am just splitting the firstandlast string into two parts and returning the first past as first name and last part as last name.
I thought perhaps I should be reading documentation on getters and setters, please let me know if I should not or whether should clear all code and start again
Your code so far
var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
this.getFullName = function() {
return firstAndLast;
};
this.getFirstName = function() {
return firstAndLast.split(" ")[0];
};
var test = this.getFirstName
this.getLastName = function() {
return firstAndLast.split(" ")[1];
};
this.setLastName = function() {
return firstAndLast.split(" ")[1];
};
this.setFirstName = function() {
return firstAndLast.split(" ")[0];
};
this.setFullName = function() {
return firstAndLast;
};
return firstAndLast;
};
var bob = new Person('Bob Ross');
bob.getFullName();
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36
.
Challenge: Make a Person
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/make-a-person`