I changed the code a little bit, but I haven’t passed two tests yet.
bob.getFullName() should return “Haskell Curry” after bob.setFullName("Haskell Curry") . bob.getLastName() should return “Curry” after bob.setFullName("Haskell Curry") .
var Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
let inputData = firstAndLast.match( /\w+/ig );
let firstName = inputData[0];
let lastName = inputData[1];
let fullName;
this.getFirstName = function() {
return firstName;
};
this.getLastName = function() {
return lastName;
};
this.getFullName = function() {
return fullName = firstName + " " + lastName;
};
this.setFirstName = function(first) {
return firstName = first;
};
this.setLastName = function(last) {
return lastName = last;
};
this.setFullName = function(firstAndLast) {
let arrSetFullName = firstAndLast.match( /\w+/ig );
return fullName = arrSetFullName.join(" ");
};
return firstAndLast;
};
var bob = new Person('Bob Ross');
bob.getFullName();```
Your setFirstName and setLastName methods shouldn’t return anything. That’s the purpose of your get methods. They are literally setting/updating values in your constructor. When you are updating either first/last name make sure to update fullName as well because fullName will always change if firstName or lastName changes.