Tell us what’s happening:
As a standalone line in the terminal, my setter works fine, however, in this context the program throws me an invalid regex group
error. Don’t know why, honestly, help please.
Your code so far
let Person = function(firstAndLast) {
// Complete the method below and implement the others similarly
let fullName = firstAndLast;
this.getFirstName = function() {
return fullName.split(" ")[0];
};
this.getLastName = function() {
return fullName.split(" ")[1]
};
this.getFullName = function() {
return fullName;
};
this.setFirstName = function(first) {
fullName = first.concat(fullName.split(/(?=\s)/)[1]);
};
this.setLastName = function(last) {
fullName = fullName.split(/(?<=\s)/)[0].concat(last);
};
this.setFullName = function(firstAndLast) {
fullName = firstAndLast;
};
return firstAndLast;
};
let bob = new Person('Bob Ross');
bob.getFullName();
Your browser information:
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/make-a-person/