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: