# Can anyone suggest whats wrong in the code?

**URL:** <https://forum.freecodecamp.org/t/can-anyone-suggest-whats-wrong-in-the-code/472775>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [August 7, 2021, 4:33pm UTC](https://forum.freecodecamp.org/t/can-anyone-suggest-whats-wrong-in-the-code/472775 "2021-08-07T16:33:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vikash-JS](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/vikash-js/32/228107_2.png) [@Vikash-JS](https://forum.freecodecamp.org/u/Vikash-JS)\
**Post date:** [August 7, 2021, 4:33pm UTC](https://forum.freecodecamp.org/t/can-anyone-suggest-whats-wrong-in-the-code/472775/1 "2021-08-07T16:33:35Z")

</div>

getFullName is still set to the one applied earliest even after setting it afterwards.  
I am new to JS, can anyone please suggest what am I doing wrong?

```auto
var Person = function(firstAndLast) {
 let fullName = firstAndLast;
 this.getFirstName = () => fullName.split(' ')[0];
 this.getLastName = () => fullName.split(' ')[1];
 this.getFullName = () => fullName;
 this.setFirstName = first => fullName = first + " " + fullName.split(" ")[1];
 this.setLastName = last => fullName = fullName.split(" ")[0] + " " + last ;
 this.setFullName = firstAndLast => firstAndLast; 
}

var bob = new Person('Bob Ross');
bob.setFullName("Haskell Curry")
console.log(bob.getFullName())

```

---

<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:** [August 7, 2021, 4:34pm UTC](https://forum.freecodecamp.org/t/can-anyone-suggest-whats-wrong-in-the-code/472775/2 "2021-08-07T16:34:41Z")

</div>

Can you post a link to the challenge please?

* * *

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (`</>`) to add backticks around text.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](https://forum.freecodecamp.org/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (’).

---

<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:** [August 7, 2021, 4:36pm UTC](https://forum.freecodecamp.org/t/can-anyone-suggest-whats-wrong-in-the-code/472775/3 "2021-08-07T16:36:18Z")

</div>

> [@Vikash-JS](#):
>
> `firstAndLast => firstAndLast`

I think this isn’t setting `fullName`

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [February 6, 2022, 4:36am UTC](https://forum.freecodecamp.org/t/can-anyone-suggest-whats-wrong-in-the-code/472775/4 "2022-02-06T04:36:29Z")

</div>

Closed on February 6, 2022, 4:36am UTC

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
