Make A Person Test Error

I have completed the Make A Person. For whatever reason, the test is looking for 6 Object keys but the person has been built to specifications.

Here’s a link: [https://www.freecodecamp.com/challenges/make-a-person]

Here’s the code:

var Person = function(firstAndLast) {
this.setFullName(firstAndLast);
};

Person.prototype.setFirstName = function(first) {
  this.first = first;
  this.firstAndLast = (this.first + " " + this.last);
};

Person.prototype.setLastName = function(last) {
  this.last = last;
  this.firstAndLast = (this.first + " " + this.last);
};

Person.prototype.setFullName = function(firstAndLast) {
  this.firstAndLast = firstAndLast;
  var nameArr = firstAndLast.split(" ");
  this.first = nameArr[0];
  this.last = nameArr[1];
};

Person.prototype.getFullName = function() {
  return this.firstAndLast;
};

Person.prototype.getFirstName = function() {
  return this.first;
};

Person.prototype.getLastName = function() {
  return this.last;
};

var bob = new Person('Bob Ross');

[spoiler]```
var Person = function(firstAndLast) {
var nameArr = firstAndLast.split(" “);
this.getFirstName = function() {
return nameArr[0];
};
this.getLastName = function() {
return nameArr[1];
};
this.getFullName = function() {
return nameArr.join(’ ');
};
this.setFirstName = function(first) {
nameArr[0] = first;
};
this.setLastName = function(last) {
nameArr[1] = last;
};
this.setFullName = function(firstAndLast) {
nameArr = firstAndLast.split(” ");
};

};

var bob = new Person(‘Bob Ross’);

Don’t mean to sound rude but posting the solution is not a help, but quite opposite.

2 Likes

The intention is to see whether you know how to and able to create private member of the object constructor. Thus it expects only functions to be visible, hence 6 items are expected.

Please refer to this post for further explanation in much better way that I could do it: http://www.crockford.com/javascript/private.html

watch this video -

then see if you can code it, if not, read this FCC wiki -

FreeCodeCamp - wiki; Make A Person

You are not being rude at all, that first post with the solution and no commentary is actually super rude and disrespectful (IMO), but whatever right :wink:

Did the video help?

1 Like

I thought I’d reply with a little extra even though the video does an awesome job and he clearly knows way more than me.

Why didn’t you build it all into a single object rather than building several prototypes? If you look at
http://www.objectplayground.com/
6:05min into the video you’ll see him declare that each prototype is an object and the instructions I believe state only a single object with all 6 should be used.

Lastly I think it’s cool how you did this, way way extra work, but super interesting. I hadn’t and didn’t even consider this pathway forward. Good for you for exploring another way!!

Cheers

Good point. If you see something like this again, feel free to flag as inappropriate, and we will take care of it.

Also, I don’t think this really belongs in the wiki, moving it to Help/Questions.

2 Likes