# Make a Person making me crazy

**URL:** <https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [May 23, 2020, 8:31pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231 "2020-05-23T20:31:08Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![opalko](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/opalko/32/158640_2.png) [@opalko](https://forum.freecodecamp.org/u/opalko)\
**Post date:** [May 23, 2020, 8:31pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/1 "2020-05-23T20:31:08Z")

</div>

**Tell us what’s happening:**  
Gone back and forth on this so many times I can’t figure out why it isn’t being accepted.  
All my test runs match the expected output in the tests but no dice.

**Your code so far**

```js

//
// Fill in the object constructor with the following methods below:
//
// getFirstName()
// getLastName()
// getFullName()
// setFirstName(first)
// setLastName(last)
// setFullName(firstAndLast)
// Run the tests to see the expected output for each method. 
// The methods that take an argument must accept only one argument 
// and it has to be a string. These methods must be the only available 
// means of interacting with the object.

var Person = function(firstAndLast) {
  // Complete the method below and implement the others similarlyN
const name = firstAndLast.split(' ');
let firstName = name[0];
let lastName = name[1];
    
this.getFirstName = function() {
  return firstName;
};
this.getLastName = function() {
  return lastName;
}
this.getFullName = function() {
  return firstName + " " + lastName;  
}
this.setFirstName = function(fName) {
  firstName = fName;

}
this.setLastName = function(lName) {
  lastName = lName;

}
this.setFullName = function(fulName) {
  firstAndLast = fulName;
}    
};

var bob = new Person('Bob Ross');
console.log(bob.getFirstName());
bob.setFirstName("Haskell");
console.log(bob.getFirstName());
console.log(bob.getFullName());
bob.setLastName("Curry");
console.log(bob.getFullName());
console.log(bob.getFirstName());
console.log(bob.getLastName());

```

**Your browser information:**

User Agent is: `Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36`.

**Challenge:** Make a Person

**Link to the challenge:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/make-a-person)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [May 23, 2020, 8:35pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/2 "2020-05-23T20:35:12Z")

</div>

If I’m not mistaken, you are missing the `this.` on the internal object variables.

---

<div class="post-metadata">

**Author:** ![opalko](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/opalko/32/158640_2.png) [@opalko](https://forum.freecodecamp.org/u/opalko)\
**Post date:** [May 23, 2020, 8:37pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/3 "2020-05-23T20:37:58Z")

</div>

Like these?

```auto
this.setFullName = function(fulName)

```

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [May 23, 2020, 8:43pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/4 "2020-05-23T20:43:32Z")

</div>

You have `let firstName` when I think you want `this.firstName` and such.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [May 23, 2020, 8:44pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/5 "2020-05-23T20:44:19Z")

</div>

no, those should not be object properties as you need 6 properties on the object and those are all the methods

---

<div class="post-metadata">

**Author:** ![kerafyrm](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kerafyrm](https://forum.freecodecamp.org/u/kerafyrm)\
**Post date:** [May 23, 2020, 8:48pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/6 "2020-05-23T20:48:00Z")

</div>

setFullName is wrong.

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [May 23, 2020, 8:48pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/7 "2020-05-23T20:48:09Z")

</div>

Yeah, you’re right. My mistake, I missread that part.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [May 23, 2020, 8:48pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/8 "2020-05-23T20:48:43Z")

</div>

I think you need to remove all the set methods calls you have, as the tests are testing the `bob` object created in the challenge  
edit: and as @kerafyrm say you have `setFullName` not doing what you want (you are not updating variables `firstName` and `lastName`)

@JeremyLT: do you want to create an issue on github for this? it seems an unnecessary headache

---

<div class="post-metadata">

**Author:** ![kerafyrm](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kerafyrm](https://forum.freecodecamp.org/u/kerafyrm)\
**Post date:** [May 23, 2020, 8:50pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/9 "2020-05-23T20:50:17Z")

</div>

look at his setFullName function.

he has `firstAndLast`

---

<div class="post-metadata">

**Author:** ![opalko](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/opalko/32/158640_2.png) [@opalko](https://forum.freecodecamp.org/u/opalko)\
**Post date:** [May 23, 2020, 8:54pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/10 "2020-05-23T20:54:52Z")

</div>

Are you referring to removing the console.log statements where I am testing?

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [May 23, 2020, 8:56pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/11 "2020-05-23T20:56:27Z")

</div>

Is this how private variables are managed for an object? Huh.

I agree that we should tweak the test or add a `// Don't change code below... `.

@opalko, I was wrong at first. Ignore that.

You have two problems, as far as I can tell.

1. Your private variables are only ` firstName` and `lastName` in the way you’ve set this up. You need to update `setFullName` to only use those variables.
2. You probably shouldn’t change the Bob object after it’s created when you submit the code.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [May 23, 2020, 8:56pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/12 "2020-05-23T20:56:39Z")

</div>

the tests are checking what `bob.getFirstName()` returns, but you have changed the first name with the use of `bob.setFirstName()` so the test fail

---

<div class="post-metadata">

**Author:** ![kerafyrm](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kerafyrm](https://forum.freecodecamp.org/u/kerafyrm)\
**Post date:** [May 23, 2020, 8:58pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/13 "2020-05-23T20:58:12Z")

</div>

```auto
this.setFullName = function(fulName){
   [firstName, lastName] = fulName.split(' ');
}

```

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [May 23, 2020, 8:59pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/14 "2020-05-23T20:59:12Z")

</div>

It’s great that you know how to do this, but we prefer to help users develop their own code rather than giving them solutions. Thanks for understanding.

---

<div class="post-metadata">

**Author:** ![opalko](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/opalko/32/158640_2.png) [@opalko](https://forum.freecodecamp.org/u/opalko)\
**Post date:** [May 23, 2020, 8:59pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/15 "2020-05-23T20:59:53Z")

</div>

Ok I am really lost now. Github? Great I know how to do this?..

---

<div class="post-metadata">

**Author:** ![kerafyrm](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kerafyrm](https://forum.freecodecamp.org/u/kerafyrm)\
**Post date:** [May 23, 2020, 9:01pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/16 "2020-05-23T21:01:13Z")

</div>

I had the impression the moderators were about to submit a bug in the problem when there was none.

Using `this` is not required. Those variables become “private” properties of that object by virtue of them in the object’s scope.

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [May 23, 2020, 9:02pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/17 "2020-05-23T21:02:10Z")

</div>

OK. Ignore the thread so for @opalko .

You have in your `setFullName` a reference to a variable that does not exist. `firstAndLast` isn’t in your object, as you have set it up. You should instead use the same logic as your constructor and use the two variables you have, `firstName` and `lastName`.

Please let me know if I can be clearer.

After than, you’ll want to remove all of the code after `var bob = new Person("Bob Ross") ;`

---

<div class="post-metadata">

**Author:** ![kerafyrm](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kerafyrm](https://forum.freecodecamp.org/u/kerafyrm)\
**Post date:** [May 23, 2020, 9:06pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/18 "2020-05-23T21:06:53Z")

</div>

Your problem was very simple. You did almost everything correctly.

you had a method called: `setFullName` but it didn’t really set it.

Notice how your other set methods set the firstName variable and lastName variable correctly.

When setting the fullName you need to reassign the firstName and lastName values individually.

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [May 23, 2020, 9:07pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/19 "2020-05-23T21:07:39Z")

</div>

if everything is fine but I add  
`bob.setFirstName("Cindy")` the following test fail:

> `bob.getFirstName()` should return `"Bob"`.

Which is what’s happening for most of the not passing tests in case of OP code

---

<div class="post-metadata">

**Author:** ![opalko](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/opalko/32/158640_2.png) [@opalko](https://forum.freecodecamp.org/u/opalko)\
**Post date:** [May 23, 2020, 9:15pm UTC](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231/20 "2020-05-23T21:15:31Z")

</div>

So I can repeat the first few lines and it works

```auto
this.setFullName = function(fulName) {
    firstAndLast = fulName.split(" ");
    firstName = firstAndLast[0];
    lastName = firstAndLast[1];
    firstAndLast = firstName + " " + lastName;
  }    

```

[Next page](https://forum.freecodecamp.org/t/make-a-person-making-me-crazy/393231.md?page=2)
