How to get someone's first and last name when they enter their full name if someone's first and/or last name is more than 1 word each? Like for example "Juan García Reyes" where "García Reyes" is the last name, or "Anne Marie Smith" where Anne Marie is the first name.? I have this:
set fullName(value) {
const parts = value.split(" ");
this.firstName = parts[?];
this.lastName = parts[?]
}
or this:
set fullName(value) {
[this.firstName, this.lastName] = value.split(' ');
}
but they only work when the first and last name are both only 1 word. I'm a beginner so please forgive me if this is a bit stupid!