Welcome tag moderator AKA Unofficial DEV cheerleader. While most of my friends are found on SnapChat or Tic-Toc, you can find me here. And I OOP, but Iām not a VSCO girl.
In that case, you could customize your lastNameIsValid to something like this, so it allows for blank last names :)
functionlastNameIsValid(lastName){if(!lastName||lastName.length<=10){returntrue;}else{errorMessages.push('Last name cannot be longer than 10 characters');returnfalse;}}
Will your solution work if the person only has a first name like Cher or Madonna?
In that case, you could customize your
lastNameIsValid
to something like this, so it allows for blank last names :)Results: