This is why I´m scared of starting building on React
Reached the challenge https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/make-a-person and I can´t remember how objects really work still
So I managed to do the “getters” tests. But once I try to the “setter” I can´t wrap my head around what I´m exactly doing.
Can you tell me what is wrong about this code? (what I remarked between double asterics is what is not working obviously)
var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
**FullName: this.FullName**,
this.getFirstName = function(){
return "Bob"
}
this.getLastName = function(){
return 'Ross'
}
this.getFullName = function() {
return "Bob Ross";
};
this.setFullName = function(name){
**this.FullName = name;**
}
return firstAndLast;
};
var bob = new Person('Bob Ross');
bob.setFullName("Hola Chico");
bob.getFullName; // RETURNS "function" when it should return "Hola Chico"
Basically I´m confused in how to create the attributes FirstName, FullName, and LastName to then make setters to them, since I only know how to do them when they are also working as an argument to the “big function” (in this case the only argument apparently is “firstAndLast”).