JavaScript-Name-Parser
JavaScript-Name-Parser copied to clipboard
Does not work for last name Ma
Jack Ma is parsed as first name Jack and suffix MA, no last name.
Yeah, it's a suffix for Master of Arts. You could remove it from the suffixArray.
A check could be added that if the last name is empty but a suffix is found, maybe ignore the suffix assignment. Also could check to see if it's mixed case as normally it would be written as MA.
Maybe something like this toward the end.
if (suffix !== "" && lastName === "") {
suffix = "";
lastName = nameParts[numWords - 1];
}