Make a person ... stuck here!

Tell us what’s happening:
i’m failing to pass these two tests
bob.getFirstName() should return “Haskell” after bob.setFullName("Haskell Curry") .

bob.getLastName() should return “Curry” after bob.setFullName("Haskell Curry") .

Your code so far


var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
let arr = firstAndLast.split(" ");
let firstName = arr[0];
let lastName = arr[1];
let fullName = firstName + " " + lastName;

this.getFirstName = function() {
  return firstName;
};

this.getLastName = function() {
  return lastName;
};

this.getFullName = function() {
  return fullName;
};

this.setFirstName = function(first) {
  fullName = first + " " + lastName;
};

this.setLastName = function(last) {
  fullName = firstName + " " + last;
};

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

};

var bob = new Person('Bob Ross');
console.log(bob.getFullName());
console.log(bob.getFirstName())
console.log(bob.getLastName())

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36.

Challenge: Make a Person

Link to the challenge:

You have to move some of the functionality (the code at the top) you have outside the methods inside them.

here you have these
notice tho that you only update fullName, never update firstName or lastName, but then you return them

i modified the setter methods a bit and i worked


this.setFirstName = function(first) {
    firstName = first;
    fullName = firstName + " " + lastName;
  };

  this.setLastName = function(last) {
    lastName = last;
    fullName = firstName + " " + lastName;
  };

  this.setFullName = function(firstAndLast) {
    let newArr = firstAndLast.split(" ");
    firstName = newArr[0];
    lastName = newArr[1];
    fullName = firstName + " " + lastName;
  };