Make a Person How I could reference the inside and outside argument?

Tell us what’s happening:

The code is not working but I guess it’s because that the method setFullName doesn’t know which variable/argument to edit, I guess? How I fix this?

Your code so far


var Person = function(firstAndLast) {
  // Complete the method below and implement the others similarly
  var firstAndLast = firstAndLast.split(" ");
  this.getFullName = function() {
    return firstAndLast.join(" ");
  };
  this.getFirstName = function() {
    return firstAndLast[0];
  };
  this.getLastName = function() {
    return firstAndLast[1];
  };
  this.setFirstName = function(first) {
    firstAndLast[0] = first;
  }
  this.setLastName = function(last) {
    firstAndLast[1] = last;
  }
  this.setFullName = function(firstAndLast) {
   firstAndLast = firstAndLast;
  }
};

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/make-a-person

It’s generally bad practice to name a variable in a function the same thing as a named argument.

Call it something different: it’s up to you what the argument is called, it doesn’t have any special meaning.

Not my mistake. The challenge says so.

What are you talking about? The challenge doesn’t tell you what to name your variables.

Fill in the object constructor with the following methods below:

getFirstName() getLastName() getFullName() setFirstName(first) setLastName(last) **_setFullName(firstAndLast)_**

Then call the internal variable something different?

I was trying to find a solution for this situation so in future, I would know what to do if I fallen in the same situation where I have to select a method with the argument name as the constructor main argument.

But after researching, it seems that it is pretty impossible. So yeah, I guess the only solution is to avoid this situation. Anyway, I solved it minutes ago. Thank you for help.

Having the method argument named the same thing as the constructor’s argument isn’t a problem. It’s just a bad idea to name a variable the same thing as an argument.