I am lost in the Make a Person Challenge

Tell us what’s happening:
I don’t get exactly how I am going to turn the first and last names into a function: “getFirstName()” and “getLastName()”. There are a lot of tutorials about getters and setters, but most of them show this code:

function Name(first, last) {
this.first = first;
this.last = last;
}

Name.prototype = {
get fullName() {
return this.first + " " + this.last;
},

set fullName(name) {
    var names = name.split(" ");
    this.first = names[0];
    this.last = names[1];
}

};

It didn’t work. The “make a person” challenge solution looks easy, but I don’t know how to find it.

Your code so far


var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
this.getFullName = function() {
  return "Bob Ross";
};
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/81.0.4044.138 Safari/537.36.

Challenge: Make a Person

Link to the challenge:

first: you have the 6 required methods to implement, and the object should have exactly 6 properties: so you need to use a way to store the name that is not a property, and give it a starting value that comes from the parameter

second: start with trying to implement the first method.
Also note that here you are not using getters and setters, but just functions that have the get and set words in their name

1 Like