Normalize names with string cleanup and formatting functions.
A signup form is receiving names with inconsistent spacing and casing. Normalize the names before showing them back to the user.
Write these functions:
cleanText(text) should remove spaces from the start and end of a string.
capitalize(text) should uppercase the first character and lowercase the rest.
formatDisplayName(firstName, lastName) should clean and capitalize both names, then return the full display name.
Sample checks:
Expected output:
formatDisplayName should reuse the smaller helpers instead of repeating all the string cleanup work.
Join the Community
roadmap.sh is the most starred project on GitHub and is visited by hundreds of thousands of developers every month.
Roadmaps Best Practices Guides Videos FAQs YouTube
roadmap.sh by @kamrify @kamrify
Community created roadmaps, best practices, projects, articles, resources and journeys to help you choose your path and grow in your career.
Login or Signup
You must be logged in to perform this action.